test: Add integration test that simulates running 2 hours

This commit is contained in:
Joachim Van Herwegen 2022-03-31 14:55:49 +02:00
parent f08cdf75f7
commit ce5a98b16f
2 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,39 @@
import fetch from 'cross-fetch';
import type { App } from '../../src/init/App';
import { getPort } from '../util/Util';
import {
getDefaultVariables,
getTestConfigPath,
instantiateFromConfig,
} from './Config';
jest.useFakeTimers('legacy');
const port = getPort('ExpiringDataCleanup');
const baseUrl = `http://localhost:${port}/`;
describe('A server with expiring storage', (): void => {
let app: App;
beforeAll(async(): Promise<void> => {
const instances = await instantiateFromConfig(
'urn:solid-server:test:Instances',
getTestConfigPath('server-memory.json'),
getDefaultVariables(port, baseUrl),
) as Record<string, any>;
({ app } = instances);
await app.start();
});
afterAll(async(): Promise<void> => {
await app.stop();
});
it('does not crash after the interval timeout.', async(): Promise<void> => {
// Default timeout is 1 hour
// This test would fail if something goes wrong in an interval timer
jest.advanceTimersByTime(2 * 60 * 60 * 1000);
const res = await fetch(baseUrl, { method: 'HEAD' });
expect(res.status).toBe(200);
});
});

View File

@ -7,6 +7,7 @@ const portNames = [
'Conditions',
'ContentNegotiation',
'DynamicPods',
'ExpiringDataCleanup',
'GlobalQuota',
'Identity',
'LpdHandlerWithAuth',