Skip to content

Commit 5142591

Browse files
committed
Use fs-extras and async methods for file manipulation
1 parent 430bcd0 commit 5142591

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

extensions/ql-vscode/src/vscode-tests/no-workspace/query-results.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,11 @@ describe("query-results", () => {
189189
const interpretedResultsPath = path.join(tmpDir.name, "interpreted.json");
190190
const sourceInfo = {};
191191

192-
beforeEach(() => {
192+
beforeEach(async () => {
193193
spy.mockReturnValue({ a: "1234" });
194194

195+
await fs.ensureDir(path.basename(interpretedResultsPath));
196+
195197
mockServer = {
196198
interpretBqrsSarif: spy,
197199
} as unknown as CodeQLCliServer;

extensions/ql-vscode/src/vscode-tests/no-workspace/remote-queries/remote-query-history.test.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ describe("Remote queries and query history manager", () => {
129129
.mockResolvedValue(undefined as unknown as TextDocument);
130130
});
131131

132-
afterEach(() => {
133-
deleteHistoryState();
132+
afterEach(async () => {
133+
await deleteHistoryState();
134134
disposables.dispose(testDisposeHandler);
135135
});
136136

@@ -505,8 +505,9 @@ describe("Remote queries and query history manager", () => {
505505
});
506506

507507
async function copyHistoryState() {
508-
fs.ensureDirSync(STORAGE_DIR);
509-
fs.copySync(
508+
await fs.ensureDir(STORAGE_DIR);
509+
await fs.ensureDir(path.join(tmpDir.name, "remote-queries"));
510+
await fs.copy(
510511
path.join(__dirname, "../data/remote-queries/"),
511512
path.join(tmpDir.name, "remote-queries"),
512513
);
@@ -517,13 +518,8 @@ describe("Remote queries and query history manager", () => {
517518
}
518519
}
519520

520-
function deleteHistoryState() {
521-
fs.rmSync(STORAGE_DIR, {
522-
recursive: true,
523-
force: true,
524-
maxRetries: 10,
525-
retryDelay: 100,
526-
});
521+
async function deleteHistoryState() {
522+
await fs.remove(STORAGE_DIR);
527523
}
528524

529525
function replacePlaceholder(filePath: string) {

0 commit comments

Comments
 (0)