Merge pull request #1894 from github/charisk/add-db-integration-test
Add basic integration test for 'add db' functionality
This commit is contained in:
Коммит
55869e8033
|
@ -18,7 +18,7 @@ import { DbManager } from "../db-manager";
|
|||
import { DbTreeDataProvider } from "./db-tree-data-provider";
|
||||
import { DbTreeViewItem } from "./db-tree-view-item";
|
||||
|
||||
interface RemoteDatabaseQuickPickItem extends QuickPickItem {
|
||||
export interface RemoteDatabaseQuickPickItem extends QuickPickItem {
|
||||
kind: string;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ export class DbPanel extends DisposableObject {
|
|||
);
|
||||
this.push(
|
||||
commandRunner("codeQLDatabasesExperimental.addNewList", () =>
|
||||
this.addNewRemoteList(),
|
||||
this.addNewList(),
|
||||
),
|
||||
);
|
||||
this.push(
|
||||
|
@ -151,7 +151,7 @@ export class DbPanel extends DisposableObject {
|
|||
await this.dbManager.addNewRemoteOwner(owner);
|
||||
}
|
||||
|
||||
private async addNewRemoteList(): Promise<void> {
|
||||
private async addNewList(): Promise<void> {
|
||||
const listName = await window.showInputBox({
|
||||
prompt: "Enter a name for the new list",
|
||||
placeHolder: "example-list",
|
||||
|
|
|
@ -4,6 +4,7 @@ import { CodeQLExtensionInterface } from "../../../extension";
|
|||
import { readJson } from "fs-extra";
|
||||
import * as path from "path";
|
||||
import { DbConfig } from "../../../databases/config/db-config";
|
||||
import { RemoteDatabaseQuickPickItem } from "../../../databases/ui/db-panel";
|
||||
|
||||
jest.setTimeout(60_000);
|
||||
|
||||
|
@ -33,4 +34,36 @@ describe("Db panel UI commands", () => {
|
|||
expect(dbConfig.databases.remote.repositoryLists).toHaveLength(1);
|
||||
expect(dbConfig.databases.remote.repositoryLists[0].name).toBe("my-list-1");
|
||||
});
|
||||
|
||||
it("should add new remote repository", async () => {
|
||||
// Add db
|
||||
jest.spyOn(window, "showQuickPick").mockResolvedValue({
|
||||
kind: "repo",
|
||||
} as RemoteDatabaseQuickPickItem);
|
||||
|
||||
jest.spyOn(window, "showInputBox").mockResolvedValue("owner1/repo1");
|
||||
await commands.executeCommand("codeQLDatabasesExperimental.addNewDatabase");
|
||||
|
||||
// Check db config
|
||||
const dbConfigFilePath = path.join(storagePath, "workspace-databases.json");
|
||||
const dbConfig: DbConfig = await readJson(dbConfigFilePath);
|
||||
expect(dbConfig.databases.remote.repositories).toHaveLength(1);
|
||||
expect(dbConfig.databases.remote.repositories[0]).toBe("owner1/repo1");
|
||||
});
|
||||
|
||||
it("should add new remote owner", async () => {
|
||||
// Add owner
|
||||
jest.spyOn(window, "showQuickPick").mockResolvedValue({
|
||||
kind: "owner",
|
||||
} as RemoteDatabaseQuickPickItem);
|
||||
|
||||
jest.spyOn(window, "showInputBox").mockResolvedValue("owner1");
|
||||
await commands.executeCommand("codeQLDatabasesExperimental.addNewDatabase");
|
||||
|
||||
// Check db config
|
||||
const dbConfigFilePath = path.join(storagePath, "workspace-databases.json");
|
||||
const dbConfig: DbConfig = await readJson(dbConfigFilePath);
|
||||
expect(dbConfig.databases.remote.owners).toHaveLength(1);
|
||||
expect(dbConfig.databases.remote.owners[0]).toBe("owner1");
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче