Skip to content

Commit 7f1bced

Browse files
committed
Extract config file to constant
1 parent ecbb0fb commit 7f1bced

5 files changed

Lines changed: 47 additions & 14 deletions

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import {
3232
} from "../db-item";
3333

3434
export class DbConfigStore extends DisposableObject {
35+
static readonly databaseConfigFileName = "workspace-databases.json";
36+
3537
public readonly onDidChangeConfig: AppEvent<void>;
3638
private readonly onDidChangeConfigEventEmitter: AppEventEmitter<void>;
3739

@@ -49,7 +51,7 @@ export class DbConfigStore extends DisposableObject {
4951
super();
5052

5153
const storagePath = app.workspaceStoragePath || app.globalStoragePath;
52-
this.configPath = join(storagePath, "workspace-databases.json");
54+
this.configPath = join(storagePath, DbConfigStore.databaseConfigFileName);
5355

5456
this.config = this.createEmptyConfig();
5557
this.configErrors = [];

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

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe("db config store", () => {
4242

4343
const configPath = join(
4444
tempWorkspaceStoragePath,
45-
"workspace-databases.json",
45+
DbConfigStore.databaseConfigFileName,
4646
);
4747

4848
const configStore = new DbConfigStore(app, false);
@@ -195,7 +195,10 @@ describe("db config store", () => {
195195
workspaceStoragePath: tempWorkspaceStoragePath,
196196
});
197197

198-
configPath = join(tempWorkspaceStoragePath, "workspace-databases.json");
198+
configPath = join(
199+
tempWorkspaceStoragePath,
200+
DbConfigStore.databaseConfigFileName,
201+
);
199202
});
200203

201204
it("should add a remote repository", async () => {
@@ -320,7 +323,10 @@ describe("db config store", () => {
320323
workspaceStoragePath: tempWorkspaceStoragePath,
321324
});
322325

323-
configPath = join(tempWorkspaceStoragePath, "workspace-databases.json");
326+
configPath = join(
327+
tempWorkspaceStoragePath,
328+
DbConfigStore.databaseConfigFileName,
329+
);
324330
});
325331

326332
it("should allow renaming a remote list", async () => {
@@ -492,7 +498,10 @@ describe("db config store", () => {
492498
workspaceStoragePath: tempWorkspaceStoragePath,
493499
});
494500

495-
configPath = join(tempWorkspaceStoragePath, "workspace-databases.json");
501+
configPath = join(
502+
tempWorkspaceStoragePath,
503+
DbConfigStore.databaseConfigFileName,
504+
);
496505
});
497506

498507
it("should remove a single db item", async () => {
@@ -612,7 +621,10 @@ describe("db config store", () => {
612621
workspaceStoragePath: tempWorkspaceStoragePath,
613622
});
614623

615-
configPath = join(tempWorkspaceStoragePath, "workspace-databases.json");
624+
configPath = join(
625+
tempWorkspaceStoragePath,
626+
DbConfigStore.databaseConfigFileName,
627+
);
616628
});
617629

618630
it("should set the selected item", async () => {
@@ -648,7 +660,10 @@ describe("db config store", () => {
648660
workspaceStoragePath: tempWorkspaceStoragePath,
649661
});
650662

651-
configPath = join(tempWorkspaceStoragePath, "workspace-databases.json");
663+
configPath = join(
664+
tempWorkspaceStoragePath,
665+
DbConfigStore.databaseConfigFileName,
666+
);
652667
});
653668

654669
it("should return true if a remote owner exists", async () => {

extensions/ql-vscode/test/unit-tests/databases/db-manager.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe("db manager", () => {
5050

5151
dbConfigFilePath = join(
5252
tempWorkspaceStoragePath,
53-
"workspace-databases.json",
53+
DbConfigStore.databaseConfigFileName,
5454
);
5555
});
5656

extensions/ql-vscode/test/vscode-tests/cli-integration/databases/db-panel.test.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
import { DbListKind } from "../../../../src/databases/db-item";
1515
import { createDbTreeViewItemSystemDefinedList } from "../../../../src/databases/ui/db-tree-view-item";
1616
import { createRemoteSystemDefinedListDbItem } from "../../../factories/db-item-factories";
17+
import { DbConfigStore } from "../../../../src/databases/config/db-config-store";
1718

1819
jest.setTimeout(60_000);
1920

@@ -43,7 +44,10 @@ describe("Db panel UI commands", () => {
4344
);
4445

4546
// Check db config
46-
const dbConfigFilePath = path.join(storagePath, "workspace-databases.json");
47+
const dbConfigFilePath = path.join(
48+
storagePath,
49+
DbConfigStore.databaseConfigFileName,
50+
);
4751
const dbConfig: DbConfig = await readJson(dbConfigFilePath);
4852
expect(dbConfig.databases.variantAnalysis.repositoryLists).toHaveLength(1);
4953
expect(dbConfig.databases.variantAnalysis.repositoryLists[0].name).toBe(
@@ -62,7 +66,10 @@ describe("Db panel UI commands", () => {
6266
);
6367

6468
// Check db config
65-
const dbConfigFilePath = path.join(storagePath, "workspace-databases.json");
69+
const dbConfigFilePath = path.join(
70+
storagePath,
71+
DbConfigStore.databaseConfigFileName,
72+
);
6673
const dbConfig: DbConfig = await readJson(dbConfigFilePath);
6774
expect(dbConfig.databases.local.lists).toHaveLength(1);
6875
expect(dbConfig.databases.local.lists[0].name).toBe("my-list-1");
@@ -80,7 +87,10 @@ describe("Db panel UI commands", () => {
8087
);
8188

8289
// Check db config
83-
const dbConfigFilePath = path.join(storagePath, "workspace-databases.json");
90+
const dbConfigFilePath = path.join(
91+
storagePath,
92+
DbConfigStore.databaseConfigFileName,
93+
);
8494
const dbConfig: DbConfig = await readJson(dbConfigFilePath);
8595
expect(dbConfig.databases.variantAnalysis.repositories).toHaveLength(1);
8696
expect(dbConfig.databases.variantAnalysis.repositories[0]).toBe(
@@ -100,7 +110,10 @@ describe("Db panel UI commands", () => {
100110
);
101111

102112
// Check db config
103-
const dbConfigFilePath = path.join(storagePath, "workspace-databases.json");
113+
const dbConfigFilePath = path.join(
114+
storagePath,
115+
DbConfigStore.databaseConfigFileName,
116+
);
104117
const dbConfig: DbConfig = await readJson(dbConfigFilePath);
105118
expect(dbConfig.databases.variantAnalysis.owners).toHaveLength(1);
106119
expect(dbConfig.databases.variantAnalysis.owners[0]).toBe("owner1");
@@ -120,7 +133,10 @@ describe("Db panel UI commands", () => {
120133
);
121134

122135
// Check db config
123-
const dbConfigFilePath = path.join(storagePath, "workspace-databases.json");
136+
const dbConfigFilePath = path.join(
137+
storagePath,
138+
DbConfigStore.databaseConfigFileName,
139+
);
124140
const dbConfig: DbConfig = await readJson(dbConfigFilePath);
125141
expect(dbConfig.selected).toBeDefined();
126142
expect(dbConfig.selected).toEqual({

extensions/ql-vscode/test/vscode-tests/minimal-workspace/databases/db-panel.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe("db panel", () => {
2727
const extensionPath = join(__dirname, "../../../../");
2828
const dbConfigFilePath = join(
2929
workspaceStoragePath,
30-
"workspace-databases.json",
30+
DbConfigStore.databaseConfigFileName,
3131
);
3232
let dbTreeDataProvider: DbTreeDataProvider;
3333
let dbManager: DbManager;

0 commit comments

Comments
 (0)