mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: initial proposal for multithreaded execution
This commit is contained in:
committed by
Joachim Van Herwegen
parent
32245fc604
commit
236bbc6e5d
@@ -1,19 +1,6 @@
|
||||
import type { Logger } from '../../../../src';
|
||||
import { getLoggerFor } from '../../../../src';
|
||||
import { InternalServerError } from '../../../../src/util/errors/InternalServerError';
|
||||
import { MemoryResourceLocker } from '../../../../src/util/locking/MemoryResourceLocker';
|
||||
|
||||
jest.mock('../../../../src/logging/LogUtil', (): any => {
|
||||
const logger: Logger =
|
||||
{ error: jest.fn(), debug: jest.fn(), warn: jest.fn(), info: jest.fn(), log: jest.fn() } as any;
|
||||
return { getLoggerFor: (): Logger => logger };
|
||||
});
|
||||
const logger: jest.Mocked<Logger> = getLoggerFor('MemoryResourceLocker') as any;
|
||||
|
||||
jest.mock('cluster', (): any => ({
|
||||
isWorker: true,
|
||||
}));
|
||||
|
||||
describe('A MemoryResourceLocker', (): void => {
|
||||
let locker: MemoryResourceLocker;
|
||||
const identifier = { path: 'http://test.com/foo' };
|
||||
@@ -21,11 +8,6 @@ describe('A MemoryResourceLocker', (): void => {
|
||||
locker = new MemoryResourceLocker();
|
||||
});
|
||||
|
||||
it('logs a warning when constructed on a worker process.', (): void => {
|
||||
expect((): MemoryResourceLocker => new MemoryResourceLocker()).toBeDefined();
|
||||
expect(logger.warn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('can lock and unlock a resource.', async(): Promise<void> => {
|
||||
await expect(locker.acquire(identifier)).resolves.toBeUndefined();
|
||||
await expect(locker.release(identifier)).resolves.toBeUndefined();
|
||||
|
||||
Reference in New Issue
Block a user