| 10 | import {Filesystem} from '../src/filesystem'; |
| 11 | |
| 12 | export class MockFilesystem implements Filesystem { |
| 13 | private files = new Map<string, string>(); |
| 14 | |
| 15 | constructor(files: {[name: string]: string | undefined}) { |
| 16 | Object.keys(files).forEach((path) => this.files.set(path, files[path]!)); |
| 17 | } |
| 18 | |
| 19 | async list(dir: string): Promise<string[]> { |
| 20 | return Array.from(this.files.keys()).filter((path) => path.startsWith(dir)); |
| 21 | } |
| 22 | |
| 23 | async read(path: string): Promise<string> { |
| 24 | return this.files.get(path)!; |
| 25 | } |
| 26 | |
| 27 | async hash(path: string): Promise<string> { |
| 28 | return sha1(this.files.get(path)!); |
| 29 | } |
| 30 | |
| 31 | async write(path: string, contents: string): Promise<void> { |
| 32 | this.files.set(path, contents); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | export class HashTrackingMockFilesystem extends MockFilesystem { |
| 37 | public maxConcurrentHashings = 0; |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…