Extract config file to constant
This commit is contained in:
@@ -32,6 +32,8 @@ import {
|
||||
} from "../db-item";
|
||||
|
||||
export class DbConfigStore extends DisposableObject {
|
||||
static readonly databaseConfigFileName = "workspace-databases.json";
|
||||
|
||||
public readonly onDidChangeConfig: AppEvent<void>;
|
||||
private readonly onDidChangeConfigEventEmitter: AppEventEmitter<void>;
|
||||
|
||||
@@ -49,7 +51,7 @@ export class DbConfigStore extends DisposableObject {
|
||||
super();
|
||||
|
||||
const storagePath = app.workspaceStoragePath || app.globalStoragePath;
|
||||
this.configPath = join(storagePath, "workspace-databases.json");
|
||||
this.configPath = join(storagePath, DbConfigStore.databaseConfigFileName);
|
||||
|
||||
this.config = this.createEmptyConfig();
|
||||
this.configErrors = [];
|
||||
|
||||
@@ -42,7 +42,7 @@ describe("db config store", () => {
|
||||
|
||||
const configPath = join(
|
||||
tempWorkspaceStoragePath,
|
||||
"workspace-databases.json",
|
||||
DbConfigStore.databaseConfigFileName,
|
||||
);
|
||||
|
||||
const configStore = new DbConfigStore(app, false);
|
||||
@@ -195,7 +195,10 @@ describe("db config store", () => {
|
||||
workspaceStoragePath: tempWorkspaceStoragePath,
|
||||
});
|
||||
|
||||
configPath = join(tempWorkspaceStoragePath, "workspace-databases.json");
|
||||
configPath = join(
|
||||
tempWorkspaceStoragePath,
|
||||
DbConfigStore.databaseConfigFileName,
|
||||
);
|
||||
});
|
||||
|
||||
it("should add a remote repository", async () => {
|
||||
@@ -320,7 +323,10 @@ describe("db config store", () => {
|
||||
workspaceStoragePath: tempWorkspaceStoragePath,
|
||||
});
|
||||
|
||||
configPath = join(tempWorkspaceStoragePath, "workspace-databases.json");
|
||||
configPath = join(
|
||||
tempWorkspaceStoragePath,
|
||||
DbConfigStore.databaseConfigFileName,
|
||||
);
|
||||
});
|
||||
|
||||
it("should allow renaming a remote list", async () => {
|
||||
@@ -492,7 +498,10 @@ describe("db config store", () => {
|
||||
workspaceStoragePath: tempWorkspaceStoragePath,
|
||||
});
|
||||
|
||||
configPath = join(tempWorkspaceStoragePath, "workspace-databases.json");
|
||||
configPath = join(
|
||||
tempWorkspaceStoragePath,
|
||||
DbConfigStore.databaseConfigFileName,
|
||||
);
|
||||
});
|
||||
|
||||
it("should remove a single db item", async () => {
|
||||
@@ -612,7 +621,10 @@ describe("db config store", () => {
|
||||
workspaceStoragePath: tempWorkspaceStoragePath,
|
||||
});
|
||||
|
||||
configPath = join(tempWorkspaceStoragePath, "workspace-databases.json");
|
||||
configPath = join(
|
||||
tempWorkspaceStoragePath,
|
||||
DbConfigStore.databaseConfigFileName,
|
||||
);
|
||||
});
|
||||
|
||||
it("should set the selected item", async () => {
|
||||
@@ -648,7 +660,10 @@ describe("db config store", () => {
|
||||
workspaceStoragePath: tempWorkspaceStoragePath,
|
||||
});
|
||||
|
||||
configPath = join(tempWorkspaceStoragePath, "workspace-databases.json");
|
||||
configPath = join(
|
||||
tempWorkspaceStoragePath,
|
||||
DbConfigStore.databaseConfigFileName,
|
||||
);
|
||||
});
|
||||
|
||||
it("should return true if a remote owner exists", async () => {
|
||||
|
||||
@@ -50,7 +50,7 @@ describe("db manager", () => {
|
||||
|
||||
dbConfigFilePath = join(
|
||||
tempWorkspaceStoragePath,
|
||||
"workspace-databases.json",
|
||||
DbConfigStore.databaseConfigFileName,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
import { DbListKind } from "../../../../src/databases/db-item";
|
||||
import { createDbTreeViewItemSystemDefinedList } from "../../../../src/databases/ui/db-tree-view-item";
|
||||
import { createRemoteSystemDefinedListDbItem } from "../../../factories/db-item-factories";
|
||||
import { DbConfigStore } from "../../../../src/databases/config/db-config-store";
|
||||
|
||||
jest.setTimeout(60_000);
|
||||
|
||||
@@ -43,7 +44,10 @@ describe("Db panel UI commands", () => {
|
||||
);
|
||||
|
||||
// Check db config
|
||||
const dbConfigFilePath = path.join(storagePath, "workspace-databases.json");
|
||||
const dbConfigFilePath = path.join(
|
||||
storagePath,
|
||||
DbConfigStore.databaseConfigFileName,
|
||||
);
|
||||
const dbConfig: DbConfig = await readJson(dbConfigFilePath);
|
||||
expect(dbConfig.databases.variantAnalysis.repositoryLists).toHaveLength(1);
|
||||
expect(dbConfig.databases.variantAnalysis.repositoryLists[0].name).toBe(
|
||||
@@ -62,7 +66,10 @@ describe("Db panel UI commands", () => {
|
||||
);
|
||||
|
||||
// Check db config
|
||||
const dbConfigFilePath = path.join(storagePath, "workspace-databases.json");
|
||||
const dbConfigFilePath = path.join(
|
||||
storagePath,
|
||||
DbConfigStore.databaseConfigFileName,
|
||||
);
|
||||
const dbConfig: DbConfig = await readJson(dbConfigFilePath);
|
||||
expect(dbConfig.databases.local.lists).toHaveLength(1);
|
||||
expect(dbConfig.databases.local.lists[0].name).toBe("my-list-1");
|
||||
@@ -80,7 +87,10 @@ describe("Db panel UI commands", () => {
|
||||
);
|
||||
|
||||
// Check db config
|
||||
const dbConfigFilePath = path.join(storagePath, "workspace-databases.json");
|
||||
const dbConfigFilePath = path.join(
|
||||
storagePath,
|
||||
DbConfigStore.databaseConfigFileName,
|
||||
);
|
||||
const dbConfig: DbConfig = await readJson(dbConfigFilePath);
|
||||
expect(dbConfig.databases.variantAnalysis.repositories).toHaveLength(1);
|
||||
expect(dbConfig.databases.variantAnalysis.repositories[0]).toBe(
|
||||
@@ -100,7 +110,10 @@ describe("Db panel UI commands", () => {
|
||||
);
|
||||
|
||||
// Check db config
|
||||
const dbConfigFilePath = path.join(storagePath, "workspace-databases.json");
|
||||
const dbConfigFilePath = path.join(
|
||||
storagePath,
|
||||
DbConfigStore.databaseConfigFileName,
|
||||
);
|
||||
const dbConfig: DbConfig = await readJson(dbConfigFilePath);
|
||||
expect(dbConfig.databases.variantAnalysis.owners).toHaveLength(1);
|
||||
expect(dbConfig.databases.variantAnalysis.owners[0]).toBe("owner1");
|
||||
@@ -120,7 +133,10 @@ describe("Db panel UI commands", () => {
|
||||
);
|
||||
|
||||
// Check db config
|
||||
const dbConfigFilePath = path.join(storagePath, "workspace-databases.json");
|
||||
const dbConfigFilePath = path.join(
|
||||
storagePath,
|
||||
DbConfigStore.databaseConfigFileName,
|
||||
);
|
||||
const dbConfig: DbConfig = await readJson(dbConfigFilePath);
|
||||
expect(dbConfig.selected).toBeDefined();
|
||||
expect(dbConfig.selected).toEqual({
|
||||
|
||||
@@ -27,7 +27,7 @@ describe("db panel", () => {
|
||||
const extensionPath = join(__dirname, "../../../../");
|
||||
const dbConfigFilePath = join(
|
||||
workspaceStoragePath,
|
||||
"workspace-databases.json",
|
||||
DbConfigStore.databaseConfigFileName,
|
||||
);
|
||||
let dbTreeDataProvider: DbTreeDataProvider;
|
||||
let dbManager: DbManager;
|
||||
|
||||
Reference in New Issue
Block a user