Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions extensions/ql-vscode/src/databases/config/db-config-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,6 @@ export class DbConfigStore extends DisposableObject {
message: `Failed to read config file: ${this.configPath}`,
},
];
await this.app.executeCommand(
"setContext",
"codeQLDatabasesExperimental.configError",
true,
);
}

if (newConfig) {
Expand All @@ -171,6 +166,11 @@ export class DbConfigStore extends DisposableObject {
);
} else {
this.config = undefined;
await this.app.executeCommand(
"setContext",
"codeQLDatabasesExperimental.configError",
true,
);
}
}

Expand All @@ -185,11 +185,6 @@ export class DbConfigStore extends DisposableObject {
message: `Failed to read config file: ${this.configPath}`,
},
];
void this.app.executeCommand(
"setContext",
"codeQLDatabasesExperimental.configError",
true,
);
}

if (newConfig) {
Expand All @@ -205,6 +200,11 @@ export class DbConfigStore extends DisposableObject {
);
} else {
this.config = undefined;
void this.app.executeCommand(
"setContext",
"codeQLDatabasesExperimental.configError",
true,
);
}
this.onDidChangeConfigEventEmitter.fire();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,39 @@ describe("db config store", () => {

configStore.dispose();
});

it("should set codeQLDatabasesExperimental.configError to true when config has error", async () => {
const testDataStoragePathInvalid = join(__dirname, "data", "invalid");

const app = createMockApp({
extensionPath,
workspaceStoragePath: testDataStoragePathInvalid,
});
const configStore = new DbConfigStore(app);
await configStore.initialize();

expect(app.executeCommand).toBeCalledWith(
"setContext",
"codeQLDatabasesExperimental.configError",
true,
);
configStore.dispose();
});

it("should set codeQLDatabasesExperimental.configError to false when config is valid", async () => {
const app = createMockApp({
extensionPath,
workspaceStoragePath: testDataStoragePath,
});
const configStore = new DbConfigStore(app);
await configStore.initialize();

expect(app.executeCommand).toBeCalledWith(
"setContext",
"codeQLDatabasesExperimental.configError",
false,
);

configStore.dispose();
});
});