mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Added resourceExists method to ResourceStore
* feat: added resourceExists method to ResourceStore * Merge remote-tracking branch 'origin/main' into feat/add-resourceExists-method-to-ResourceStore * fix: adapted to review * fix: adapted to review
This commit is contained in:
committed by
GitHub
parent
e5b7d99da4
commit
b3f292d718
@@ -39,6 +39,7 @@ describe('A LockingResourceStore', (): void => {
|
||||
setRepresentation: jest.fn((): any => addOrder('setRepresentation')),
|
||||
deleteResource: jest.fn((): any => addOrder('deleteResource')),
|
||||
modifyResource: jest.fn((): any => addOrder('modifyResource')),
|
||||
resourceExists: jest.fn((): any => addOrder('resourceExists')),
|
||||
};
|
||||
|
||||
timeoutTrigger = new EventEmitter();
|
||||
@@ -285,4 +286,13 @@ describe('A LockingResourceStore', (): void => {
|
||||
expect(source.getRepresentation).toHaveBeenCalledTimes(1);
|
||||
expect(order).toEqual([ 'lock read', 'useless get', 'timeout', 'unlock read' ]);
|
||||
});
|
||||
|
||||
it('resourceExists should only acquire and release the read lock.', async(): Promise<void> => {
|
||||
await store.resourceExists(associatedId);
|
||||
expect(locker.withReadLock).toHaveBeenCalledTimes(1);
|
||||
expect(locker.withWriteLock).toHaveBeenCalledTimes(0);
|
||||
expect(source.resourceExists).toHaveBeenCalledTimes(1);
|
||||
expect(source.resourceExists).toHaveBeenLastCalledWith(associatedId, undefined);
|
||||
expect(order).toEqual([ 'lock read', 'resourceExists', 'unlock read' ]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user