mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Use fs-extra instead of fs to simplify file access
* refactor: use fs-extra instead of fs * tests: manual mocks for fs-extra base + ensureDir * refactor: mockFileSystem + mockFs and mockFsExtra * add remove mock and some further test tweaks * test: FileDataAccessor tests passing * refactor: remove try-catch due to fs-extra handlin * refactor: fs-extra in atomicFileDataAccessor * refactor: AtomicFileDataAccessor fs-extra * test: fix coverage * refactor: use read/writeJson from fs-extra * refactor: less duplicate mocking code * refactor: re-use opendir mocking code
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import type { ResourceIdentifier } from '../../../../src/http/representation/ResourceIdentifier';
|
||||
import { JsonFileStorage } from '../../../../src/storage/keyvalue/JsonFileStorage';
|
||||
import type { ReadWriteLocker } from '../../../../src/util/locking/ReadWriteLocker';
|
||||
import { mockFs } from '../../../util/Util';
|
||||
import { mockFileSystem } from '../../../util/Util';
|
||||
|
||||
jest.mock('fs');
|
||||
jest.mock('fs-extra');
|
||||
|
||||
describe('A JsonFileStorage', (): void => {
|
||||
const rootFilePath = 'files/';
|
||||
@@ -13,7 +14,7 @@ describe('A JsonFileStorage', (): void => {
|
||||
let storage: JsonFileStorage;
|
||||
|
||||
beforeEach(async(): Promise<void> => {
|
||||
cache = mockFs(rootFilePath);
|
||||
cache = mockFileSystem(rootFilePath);
|
||||
locker = {
|
||||
withReadLock:
|
||||
jest.fn(async(identifier: ResourceIdentifier, whileLocked: () => any): Promise<any> => await whileLocked()),
|
||||
|
||||
Reference in New Issue
Block a user