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.
This commit is contained in:
@@ -2,7 +2,7 @@ import * as fs from "fs-extra";
|
||||
import * as path from "path";
|
||||
import { cloneDbConfig, DbConfig } from "./db-config";
|
||||
import * as chokidar from "chokidar";
|
||||
import { DisposableObject } from "../../pure/disposable-object";
|
||||
import { DisposableObject, DisposeHandler } from "../../pure/disposable-object";
|
||||
import { DbConfigValidator } from "./db-config-validator";
|
||||
import { ValueResult } from "../../common/value-result";
|
||||
import { App } from "../../common/app";
|
||||
@@ -38,7 +38,8 @@ export class DbConfigStore extends DisposableObject {
|
||||
this.watchConfig();
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
public dispose(disposeHandler?: DisposeHandler): void {
|
||||
super.dispose(disposeHandler);
|
||||
this.configWatcher?.unwatch(this.configPath);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ describe("db config store", () => {
|
||||
expect(config.databases.local.lists).toHaveLength(0);
|
||||
expect(config.databases.local.databases).toHaveLength(0);
|
||||
expect(config.selected).toBeUndefined();
|
||||
|
||||
configStore.dispose();
|
||||
});
|
||||
|
||||
it("should load an existing config", async () => {
|
||||
@@ -85,6 +87,8 @@ describe("db config store", () => {
|
||||
kind: "configDefined",
|
||||
value: "path.to.database",
|
||||
});
|
||||
|
||||
configStore.dispose();
|
||||
});
|
||||
|
||||
it("should load an existing config without selected db", async () => {
|
||||
@@ -104,6 +108,8 @@ describe("db config store", () => {
|
||||
|
||||
const config = configStore.getConfig().value;
|
||||
expect(config.selected).toBeUndefined();
|
||||
|
||||
configStore.dispose();
|
||||
});
|
||||
|
||||
it("should not allow modification of the config", async () => {
|
||||
@@ -119,5 +125,7 @@ describe("db config store", () => {
|
||||
|
||||
const reRetrievedConfig = configStore.getConfig().value;
|
||||
expect(reRetrievedConfig.databases.remote.repositoryLists).toHaveLength(1);
|
||||
|
||||
configStore.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user