Skip to content

Commit ec60f3f

Browse files
committed
Dispose config store in tests
The config store was not being disposed in tests, resulting in Chokidar watchers being left open. This was causing tests to not exit since there were still open file descriptors. This commit also fixes the `DbConfigStore` to make the correct `super` call in its `dispose` method.
1 parent 0974700 commit ec60f3f

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

extensions/ql-vscode/src/databases/config/db-config-store.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as fs from "fs-extra";
22
import * as path from "path";
33
import { cloneDbConfig, DbConfig } from "./db-config";
44
import * as chokidar from "chokidar";
5-
import { DisposableObject } from "../../pure/disposable-object";
5+
import { DisposableObject, DisposeHandler } from "../../pure/disposable-object";
66
import { DbConfigValidator } from "./db-config-validator";
77
import { ValueResult } from "../../common/value-result";
88
import { App } from "../../common/app";
@@ -38,7 +38,8 @@ export class DbConfigStore extends DisposableObject {
3838
this.watchConfig();
3939
}
4040

41-
public dispose(): void {
41+
public dispose(disposeHandler?: DisposeHandler): void {
42+
super.dispose(disposeHandler);
4243
this.configWatcher?.unwatch(this.configPath);
4344
}
4445

extensions/ql-vscode/test/pure-tests/databases/config/db-config-store.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ describe("db config store", () => {
3939
expect(config.databases.local.lists).toHaveLength(0);
4040
expect(config.databases.local.databases).toHaveLength(0);
4141
expect(config.selected).toBeUndefined();
42+
43+
configStore.dispose();
4244
});
4345

4446
it("should load an existing config", async () => {
@@ -85,6 +87,8 @@ describe("db config store", () => {
8587
kind: "configDefined",
8688
value: "path.to.database",
8789
});
90+
91+
configStore.dispose();
8892
});
8993

9094
it("should load an existing config without selected db", async () => {
@@ -104,6 +108,8 @@ describe("db config store", () => {
104108

105109
const config = configStore.getConfig().value;
106110
expect(config.selected).toBeUndefined();
111+
112+
configStore.dispose();
107113
});
108114

109115
it("should not allow modification of the config", async () => {
@@ -119,5 +125,7 @@ describe("db config store", () => {
119125

120126
const reRetrievedConfig = configStore.getConfig().value;
121127
expect(reRetrievedConfig.databases.remote.repositoryLists).toHaveLength(1);
128+
129+
configStore.dispose();
122130
});
123131
});

0 commit comments

Comments
 (0)