forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmockFileSystem.ts
More file actions
29 lines (26 loc) · 1003 Bytes
/
mockFileSystem.ts
File metadata and controls
29 lines (26 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { Uri } from 'vscode';
import { DataScienceFileSystem } from '../../client/datascience/dataScienceFileSystem';
import { FakeVSCodeFileSystemAPI } from '../serviceRegistry';
export class MockFileSystem extends DataScienceFileSystem {
private contentOverloads = new Map<string, string>();
constructor() {
super();
this.vscfs = new FakeVSCodeFileSystemAPI();
}
public async readLocalFile(filePath: string): Promise<string> {
const contents = this.contentOverloads.get(filePath);
if (contents) {
return contents;
}
return super.readLocalFile(filePath);
}
public async readFile(filePath: Uri): Promise<string> {
return this.readLocalFile(filePath.fsPath);
}
public addFileContents(filePath: string, contents: string): void {
this.contentOverloads.set(filePath, contents);
}
}