Naively convert DatabaseFetcher to a class
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@ import { window } from "vscode";
|
||||
import type { Octokit } from "@octokit/rest";
|
||||
import { showNeverAskAgainDialog } from "../../common/vscode/dialog";
|
||||
import { getLanguageDisplayName } from "../../common/query-language";
|
||||
import { downloadGitHubDatabaseFromUrl } from "../database-fetcher";
|
||||
import type { DatabaseFetcher } from "../database-fetcher";
|
||||
import { withProgress } from "../../common/vscode/progress";
|
||||
import type { DatabaseManager } from "../local-databases";
|
||||
import type { CodeQLCliServer } from "../../codeql-cli/cli";
|
||||
@@ -59,6 +59,7 @@ export async function downloadDatabaseFromGitHub(
|
||||
repo: string,
|
||||
databases: CodeqlDatabase[],
|
||||
databaseManager: DatabaseManager,
|
||||
databaseFetcher: DatabaseFetcher,
|
||||
storagePath: string,
|
||||
cliServer: CodeQLCliServer,
|
||||
commandManager: AppCommandManager,
|
||||
@@ -72,7 +73,7 @@ export async function downloadDatabaseFromGitHub(
|
||||
selectedDatabases.map((database) =>
|
||||
withProgress(
|
||||
async (progress) => {
|
||||
await downloadGitHubDatabaseFromUrl(
|
||||
await databaseFetcher.downloadGitHubDatabaseFromUrl(
|
||||
database.url,
|
||||
database.id,
|
||||
database.created_at,
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
isNewerDatabaseAvailable,
|
||||
} from "./updates";
|
||||
import type { Octokit } from "@octokit/rest";
|
||||
import type { DatabaseFetcher } from "../database-fetcher";
|
||||
|
||||
export class GitHubDatabasesModule extends DisposableObject {
|
||||
/**
|
||||
@@ -33,6 +34,7 @@ export class GitHubDatabasesModule extends DisposableObject {
|
||||
constructor(
|
||||
private readonly app: App,
|
||||
private readonly databaseManager: DatabaseManager,
|
||||
private readonly databaseFetcher: DatabaseFetcher,
|
||||
private readonly databaseStoragePath: string,
|
||||
private readonly cliServer: CodeQLCliServer,
|
||||
private readonly config: GitHubDatabaseConfig,
|
||||
@@ -43,6 +45,7 @@ export class GitHubDatabasesModule extends DisposableObject {
|
||||
public static async initialize(
|
||||
app: App,
|
||||
databaseManager: DatabaseManager,
|
||||
databaseFetcher: DatabaseFetcher,
|
||||
databaseStoragePath: string,
|
||||
cliServer: CodeQLCliServer,
|
||||
config: GitHubDatabaseConfig,
|
||||
@@ -50,6 +53,7 @@ export class GitHubDatabasesModule extends DisposableObject {
|
||||
const githubDatabasesModule = new GitHubDatabasesModule(
|
||||
app,
|
||||
databaseManager,
|
||||
databaseFetcher,
|
||||
databaseStoragePath,
|
||||
cliServer,
|
||||
config,
|
||||
@@ -186,6 +190,7 @@ export class GitHubDatabasesModule extends DisposableObject {
|
||||
repo,
|
||||
databases,
|
||||
this.databaseManager,
|
||||
this.databaseFetcher,
|
||||
this.databaseStoragePath,
|
||||
this.cliServer,
|
||||
this.app.commands,
|
||||
@@ -212,6 +217,7 @@ export class GitHubDatabasesModule extends DisposableObject {
|
||||
repo,
|
||||
databaseUpdates,
|
||||
this.databaseManager,
|
||||
this.databaseFetcher,
|
||||
this.databaseStoragePath,
|
||||
this.cliServer,
|
||||
this.app.commands,
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { CodeQLCliServer } from "../../codeql-cli/cli";
|
||||
import type { AppCommandManager } from "../../common/commands";
|
||||
import { getLanguageDisplayName } from "../../common/query-language";
|
||||
import { showNeverAskAgainDialog } from "../../common/vscode/dialog";
|
||||
import { downloadGitHubDatabaseFromUrl } from "../database-fetcher";
|
||||
import type { DatabaseFetcher } from "../database-fetcher";
|
||||
import { withProgress } from "../../common/vscode/progress";
|
||||
import { window } from "vscode";
|
||||
import type { GitHubDatabaseConfig } from "../../config";
|
||||
@@ -156,6 +156,7 @@ export async function downloadDatabaseUpdateFromGitHub(
|
||||
repo: string,
|
||||
updates: DatabaseUpdate[],
|
||||
databaseManager: DatabaseManager,
|
||||
databaseFetcher: DatabaseFetcher,
|
||||
storagePath: string,
|
||||
cliServer: CodeQLCliServer,
|
||||
commandManager: AppCommandManager,
|
||||
@@ -179,21 +180,22 @@ export async function downloadDatabaseUpdateFromGitHub(
|
||||
|
||||
return withProgress(
|
||||
async (progress) => {
|
||||
const newDatabase = await downloadGitHubDatabaseFromUrl(
|
||||
database.url,
|
||||
database.id,
|
||||
database.created_at,
|
||||
database.commit_oid ?? null,
|
||||
owner,
|
||||
repo,
|
||||
octokit,
|
||||
progress,
|
||||
databaseManager,
|
||||
storagePath,
|
||||
cliServer,
|
||||
databaseManager.currentDatabaseItem === update.databaseItem,
|
||||
update.databaseItem.hasSourceArchiveInExplorer(),
|
||||
);
|
||||
const newDatabase =
|
||||
await databaseFetcher.downloadGitHubDatabaseFromUrl(
|
||||
database.url,
|
||||
database.id,
|
||||
database.created_at,
|
||||
database.commit_oid ?? null,
|
||||
owner,
|
||||
repo,
|
||||
octokit,
|
||||
progress,
|
||||
databaseManager,
|
||||
storagePath,
|
||||
cliServer,
|
||||
databaseManager.currentDatabaseItem === update.databaseItem,
|
||||
update.databaseItem.hasSourceArchiveInExplorer(),
|
||||
);
|
||||
if (newDatabase === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,11 +42,7 @@ import {
|
||||
showAndLogExceptionWithTelemetry,
|
||||
showAndLogErrorMessage,
|
||||
} from "../common/logging";
|
||||
import {
|
||||
importArchiveDatabase,
|
||||
promptImportGithubDatabase,
|
||||
promptImportInternetDatabase,
|
||||
} from "./database-fetcher";
|
||||
import { DatabaseFetcher } from "./database-fetcher";
|
||||
import { asError, asyncFilter, getErrorMessage } from "../common/helpers-pure";
|
||||
import type { QueryRunner } from "../query-server";
|
||||
import type { App } from "../common/app";
|
||||
@@ -540,7 +536,7 @@ export class DatabaseUI extends DisposableObject {
|
||||
private async handleChooseDatabaseInternet(): Promise<void> {
|
||||
return withProgress(
|
||||
async (progress) => {
|
||||
await promptImportInternetDatabase(
|
||||
await new DatabaseFetcher().promptImportInternetDatabase(
|
||||
this.app.commands,
|
||||
this.databaseManager,
|
||||
this.storagePath,
|
||||
@@ -557,7 +553,7 @@ export class DatabaseUI extends DisposableObject {
|
||||
private async handleChooseDatabaseGithub(): Promise<void> {
|
||||
return withProgress(
|
||||
async (progress) => {
|
||||
await promptImportGithubDatabase(
|
||||
await new DatabaseFetcher().promptImportGithubDatabase(
|
||||
this.app,
|
||||
this.databaseManager,
|
||||
this.storagePath,
|
||||
@@ -712,7 +708,7 @@ export class DatabaseUI extends DisposableObject {
|
||||
try {
|
||||
// Assume user has selected an archive if the file has a .zip extension
|
||||
if (uri.path.endsWith(".zip")) {
|
||||
await importArchiveDatabase(
|
||||
await new DatabaseFetcher().importArchiveDatabase(
|
||||
this.app.commands,
|
||||
uri.toString(true),
|
||||
this.databaseManager,
|
||||
@@ -959,7 +955,7 @@ export class DatabaseUI extends DisposableObject {
|
||||
} else {
|
||||
// we are selecting a database archive. Must unzip into a workspace-controlled area
|
||||
// before importing.
|
||||
return await importArchiveDatabase(
|
||||
return await new DatabaseFetcher().importArchiveDatabase(
|
||||
this.app.commands,
|
||||
uri.toString(true),
|
||||
this.databaseManager,
|
||||
|
||||
@@ -133,6 +133,7 @@ import { OpenReferencedFileCodeLensProvider } from "./local-queries/open-referen
|
||||
import { LanguageContextStore } from "./language-context-store";
|
||||
import { LanguageSelectionPanel } from "./language-selection-panel/language-selection-panel";
|
||||
import { GitHubDatabasesModule } from "./databases/github-databases";
|
||||
import { DatabaseFetcher } from "./databases/database-fetcher";
|
||||
|
||||
/**
|
||||
* extension.ts
|
||||
@@ -881,6 +882,7 @@ async function activateWithInstalledDistribution(
|
||||
await GitHubDatabasesModule.initialize(
|
||||
app,
|
||||
dbm,
|
||||
new DatabaseFetcher(),
|
||||
getContextStoragePath(ctx),
|
||||
cliServer,
|
||||
githubDatabaseConfigListener,
|
||||
|
||||
@@ -51,6 +51,7 @@ import type { QueryTreeViewItem } from "../queries-panel/query-tree-view-item";
|
||||
import { tryGetQueryLanguage } from "../common/query-language";
|
||||
import type { LanguageContextStore } from "../language-context-store";
|
||||
import type { ExtensionApp } from "../common/vscode/vscode-app";
|
||||
import { DatabaseFetcher } from "../databases/database-fetcher";
|
||||
|
||||
export enum QuickEvalType {
|
||||
None,
|
||||
@@ -330,6 +331,7 @@ export class LocalQueries extends DisposableObject {
|
||||
progress,
|
||||
this.app,
|
||||
this.databaseManager,
|
||||
new DatabaseFetcher(),
|
||||
contextStoragePath,
|
||||
this.selectedQueryTreeViewItems,
|
||||
language,
|
||||
|
||||
@@ -19,10 +19,7 @@ import {
|
||||
UserCancellationException,
|
||||
withProgress,
|
||||
} from "../common/vscode/progress";
|
||||
import {
|
||||
askForGitHubRepo,
|
||||
downloadGitHubDatabase,
|
||||
} from "../databases/database-fetcher";
|
||||
import type { DatabaseFetcher } from "../databases/database-fetcher";
|
||||
import {
|
||||
getQlPackLocation,
|
||||
isCodespacesTemplate,
|
||||
@@ -62,6 +59,7 @@ export class SkeletonQueryWizard {
|
||||
private readonly progress: ProgressCallback,
|
||||
private readonly app: App,
|
||||
private readonly databaseManager: DatabaseManager,
|
||||
private readonly databaseFetcher: DatabaseFetcher,
|
||||
private readonly databaseStoragePath: string | undefined,
|
||||
private readonly selectedItems: readonly QueryTreeViewItem[],
|
||||
private language: QueryLanguage | undefined = undefined,
|
||||
@@ -378,13 +376,16 @@ export class SkeletonQueryWizard {
|
||||
});
|
||||
|
||||
const githubRepoNwo = QUERY_LANGUAGE_TO_DATABASE_REPO[this.language];
|
||||
const chosenRepo = await askForGitHubRepo(undefined, githubRepoNwo);
|
||||
const chosenRepo = await this.databaseFetcher.askForGitHubRepo(
|
||||
undefined,
|
||||
githubRepoNwo,
|
||||
);
|
||||
|
||||
if (!chosenRepo) {
|
||||
throw new UserCancellationException("No GitHub repository provided");
|
||||
}
|
||||
|
||||
await downloadGitHubDatabase(
|
||||
await this.databaseFetcher.downloadGitHubDatabase(
|
||||
chosenRepo,
|
||||
this.app,
|
||||
this.databaseManager,
|
||||
|
||||
@@ -29,7 +29,7 @@ import type {
|
||||
} from "../databases/local-databases";
|
||||
import type { CodeQLCliServer } from "../codeql-cli/cli";
|
||||
import { asError, assertNever, getErrorMessage } from "../common/helpers-pure";
|
||||
import { promptImportGithubDatabase } from "../databases/database-fetcher";
|
||||
import { DatabaseFetcher } from "../databases/database-fetcher";
|
||||
import type { App } from "../common/app";
|
||||
import { redactableError } from "../common/errors";
|
||||
import {
|
||||
@@ -916,16 +916,17 @@ export class ModelEditorView extends AbstractWebview<
|
||||
// the user to import the library database. We need to have the database
|
||||
// imported to the query server, so we need to register it to our workspace.
|
||||
const makeSelected = false;
|
||||
const addedDatabase = await promptImportGithubDatabase(
|
||||
this.app,
|
||||
this.databaseManager,
|
||||
this.app.workspaceStoragePath ?? this.app.globalStoragePath,
|
||||
progress,
|
||||
this.cliServer,
|
||||
this.databaseItem.language,
|
||||
makeSelected,
|
||||
false,
|
||||
);
|
||||
const addedDatabase =
|
||||
await new DatabaseFetcher().promptImportGithubDatabase(
|
||||
this.app,
|
||||
this.databaseManager,
|
||||
this.app.workspaceStoragePath ?? this.app.globalStoragePath,
|
||||
progress,
|
||||
this.cliServer,
|
||||
this.databaseItem.language,
|
||||
makeSelected,
|
||||
false,
|
||||
);
|
||||
if (!addedDatabase) {
|
||||
void this.app.logger.log("No database chosen");
|
||||
return;
|
||||
|
||||
@@ -3,10 +3,7 @@ import { Uri, window } from "vscode";
|
||||
|
||||
import type { CodeQLCliServer } from "../../../../src/codeql-cli/cli";
|
||||
import type { DatabaseManager } from "../../../../src/databases/local-databases";
|
||||
import {
|
||||
importArchiveDatabase,
|
||||
promptImportInternetDatabase,
|
||||
} from "../../../../src/databases/database-fetcher";
|
||||
import { DatabaseFetcher } from "../../../../src/databases/database-fetcher";
|
||||
import {
|
||||
cleanDatabases,
|
||||
dbLoc,
|
||||
@@ -49,7 +46,7 @@ describe("database-fetcher", () => {
|
||||
describe("importArchiveDatabase", () => {
|
||||
it("should add a database from a folder", async () => {
|
||||
const uri = Uri.file(dbLoc);
|
||||
let dbItem = await importArchiveDatabase(
|
||||
let dbItem = await new DatabaseFetcher().importArchiveDatabase(
|
||||
createMockCommandManager(),
|
||||
uri.toString(true),
|
||||
databaseManager,
|
||||
@@ -71,7 +68,7 @@ describe("database-fetcher", () => {
|
||||
// Provide a database URL when prompted
|
||||
inputBoxStub.mockResolvedValue(DB_URL);
|
||||
|
||||
let dbItem = await promptImportInternetDatabase(
|
||||
let dbItem = await new DatabaseFetcher().promptImportInternetDatabase(
|
||||
createMockCommandManager(),
|
||||
databaseManager,
|
||||
storagePath,
|
||||
|
||||
@@ -23,7 +23,7 @@ import type {
|
||||
DatabaseManager,
|
||||
FullDatabaseOptions,
|
||||
} from "../../../../src/databases/local-databases";
|
||||
import * as databaseFetcher from "../../../../src/databases/database-fetcher";
|
||||
import { DatabaseFetcher } from "../../../../src/databases/database-fetcher";
|
||||
import { createMockDB } from "../../../factories/databases/databases";
|
||||
import { asError } from "../../../../src/common/helpers-pure";
|
||||
import { Setting } from "../../../../src/config";
|
||||
@@ -42,6 +42,7 @@ describe("SkeletonQueryWizard", () => {
|
||||
let mockApp: App;
|
||||
let wizard: SkeletonQueryWizard;
|
||||
let mockDatabaseManager: DatabaseManager;
|
||||
let databaseFetcher: DatabaseFetcher;
|
||||
let dir: DirResult;
|
||||
let storagePath: string;
|
||||
let quickPickSpy: jest.SpiedFunction<typeof window.showQuickPick>;
|
||||
@@ -56,10 +57,10 @@ describe("SkeletonQueryWizard", () => {
|
||||
typeof QlPackGenerator.prototype.createExampleQlFile
|
||||
>;
|
||||
let downloadGitHubDatabaseSpy: jest.SpiedFunction<
|
||||
typeof databaseFetcher.downloadGitHubDatabase
|
||||
DatabaseFetcher["downloadGitHubDatabase"]
|
||||
>;
|
||||
let askForGitHubRepoSpy: jest.SpiedFunction<
|
||||
typeof databaseFetcher.askForGitHubRepo
|
||||
DatabaseFetcher["askForGitHubRepo"]
|
||||
>;
|
||||
let openTextDocumentSpy: jest.SpiedFunction<
|
||||
typeof workspace.openTextDocument
|
||||
@@ -115,6 +116,8 @@ describe("SkeletonQueryWizard", () => {
|
||||
},
|
||||
] as WorkspaceFolder[]);
|
||||
|
||||
databaseFetcher = new DatabaseFetcher();
|
||||
|
||||
quickPickSpy = jest.spyOn(window, "showQuickPick").mockResolvedValueOnce(
|
||||
mockedQuickPickItem({
|
||||
label: chosenLanguage,
|
||||
@@ -145,6 +148,7 @@ describe("SkeletonQueryWizard", () => {
|
||||
jest.fn(),
|
||||
mockApp,
|
||||
mockDatabaseManager,
|
||||
databaseFetcher,
|
||||
storagePath,
|
||||
selectedItems,
|
||||
);
|
||||
@@ -172,6 +176,7 @@ describe("SkeletonQueryWizard", () => {
|
||||
jest.fn(),
|
||||
mockApp,
|
||||
mockDatabaseManager,
|
||||
databaseFetcher,
|
||||
storagePath,
|
||||
selectedItems,
|
||||
QueryLanguage.Swift,
|
||||
@@ -320,6 +325,7 @@ describe("SkeletonQueryWizard", () => {
|
||||
jest.fn(),
|
||||
mockApp,
|
||||
mockDatabaseManagerWithItems,
|
||||
databaseFetcher,
|
||||
storagePath,
|
||||
selectedItems,
|
||||
);
|
||||
@@ -369,6 +375,7 @@ describe("SkeletonQueryWizard", () => {
|
||||
jest.fn(),
|
||||
mockApp,
|
||||
mockDatabaseManagerWithItems,
|
||||
databaseFetcher,
|
||||
storagePath,
|
||||
selectedItems,
|
||||
);
|
||||
@@ -504,6 +511,7 @@ describe("SkeletonQueryWizard", () => {
|
||||
jest.fn(),
|
||||
mockApp,
|
||||
mockDatabaseManager,
|
||||
databaseFetcher,
|
||||
storagePath,
|
||||
selectedItems,
|
||||
QueryLanguage.Javascript,
|
||||
@@ -725,6 +733,7 @@ describe("SkeletonQueryWizard", () => {
|
||||
jest.fn(),
|
||||
mockApp,
|
||||
mockDatabaseManager,
|
||||
databaseFetcher,
|
||||
storagePath,
|
||||
selectedItems,
|
||||
);
|
||||
@@ -754,6 +763,7 @@ describe("SkeletonQueryWizard", () => {
|
||||
jest.fn(),
|
||||
mockApp,
|
||||
mockDatabaseManager,
|
||||
databaseFetcher,
|
||||
storagePath,
|
||||
selectedItems,
|
||||
);
|
||||
@@ -787,6 +797,7 @@ describe("SkeletonQueryWizard", () => {
|
||||
jest.fn(),
|
||||
mockApp,
|
||||
mockDatabaseManager,
|
||||
databaseFetcher,
|
||||
storagePath,
|
||||
selectedItems,
|
||||
QueryLanguage.Swift,
|
||||
@@ -830,6 +841,7 @@ describe("SkeletonQueryWizard", () => {
|
||||
jest.fn(),
|
||||
mockApp,
|
||||
mockDatabaseManager,
|
||||
databaseFetcher,
|
||||
storagePath,
|
||||
selectedItems,
|
||||
);
|
||||
|
||||
@@ -7,7 +7,7 @@ import type {
|
||||
} from "../../src/databases/local-databases";
|
||||
import type { CodeQLCliServer } from "../../src/codeql-cli/cli";
|
||||
import type { CodeQLExtensionInterface } from "../../src/extension";
|
||||
import { importArchiveDatabase } from "../../src/databases/database-fetcher";
|
||||
import { DatabaseFetcher } from "../../src/databases/database-fetcher";
|
||||
import { createMockCommandManager } from "../__mocks__/commandsMock";
|
||||
|
||||
// This file contains helpers shared between tests that work with an activated extension.
|
||||
@@ -34,7 +34,7 @@ export async function ensureTestDatabase(
|
||||
// Add a database, but make sure the database manager is empty first
|
||||
await cleanDatabases(databaseManager);
|
||||
const uri = Uri.file(dbLoc);
|
||||
const maybeDbItem = await importArchiveDatabase(
|
||||
const maybeDbItem = await new DatabaseFetcher().importArchiveDatabase(
|
||||
createMockCommandManager(),
|
||||
uri.toString(true),
|
||||
databaseManager,
|
||||
|
||||
@@ -14,7 +14,7 @@ import type { DatabaseManager } from "../../../../../src/databases/local-databas
|
||||
import type { GitHubDatabaseConfig } from "../../../../../src/config";
|
||||
import type { CodeQLCliServer } from "../../../../../src/codeql-cli/cli";
|
||||
import { createMockCommandManager } from "../../../../__mocks__/commandsMock";
|
||||
import * as databaseFetcher from "../../../../../src/databases/database-fetcher";
|
||||
import { DatabaseFetcher } from "../../../../../src/databases/database-fetcher";
|
||||
import * as dialog from "../../../../../src/common/vscode/dialog";
|
||||
import type { CodeqlDatabase } from "../../../../../src/databases/github-databases/api";
|
||||
|
||||
@@ -97,6 +97,7 @@ describe("downloadDatabaseFromGitHub", () => {
|
||||
const owner = "github";
|
||||
const repo = "codeql";
|
||||
let databaseManager: DatabaseManager;
|
||||
let databaseFetcher: DatabaseFetcher;
|
||||
|
||||
const storagePath = "/a/b/c/d";
|
||||
let cliServer: CodeQLCliServer;
|
||||
@@ -117,12 +118,13 @@ describe("downloadDatabaseFromGitHub", () => {
|
||||
|
||||
let showQuickPickSpy: jest.SpiedFunction<typeof window.showQuickPick>;
|
||||
let downloadGitHubDatabaseFromUrlSpy: jest.SpiedFunction<
|
||||
typeof databaseFetcher.downloadGitHubDatabaseFromUrl
|
||||
DatabaseFetcher["downloadGitHubDatabaseFromUrl"]
|
||||
>;
|
||||
|
||||
beforeEach(() => {
|
||||
octokit = mockedObject<Octokit>({});
|
||||
databaseManager = mockedObject<DatabaseManager>({});
|
||||
databaseFetcher = new DatabaseFetcher();
|
||||
cliServer = mockedObject<CodeQLCliServer>({});
|
||||
|
||||
showQuickPickSpy = jest.spyOn(window, "showQuickPick").mockResolvedValue(
|
||||
@@ -144,6 +146,7 @@ describe("downloadDatabaseFromGitHub", () => {
|
||||
repo,
|
||||
databases,
|
||||
databaseManager,
|
||||
databaseFetcher,
|
||||
storagePath,
|
||||
cliServer,
|
||||
commandManager,
|
||||
@@ -208,6 +211,7 @@ describe("downloadDatabaseFromGitHub", () => {
|
||||
repo,
|
||||
databases,
|
||||
databaseManager,
|
||||
databaseFetcher,
|
||||
storagePath,
|
||||
cliServer,
|
||||
commandManager,
|
||||
@@ -264,6 +268,7 @@ describe("downloadDatabaseFromGitHub", () => {
|
||||
repo,
|
||||
databases,
|
||||
databaseManager,
|
||||
databaseFetcher,
|
||||
storagePath,
|
||||
cliServer,
|
||||
commandManager,
|
||||
@@ -329,6 +334,7 @@ describe("downloadDatabaseFromGitHub", () => {
|
||||
repo,
|
||||
databases,
|
||||
databaseManager,
|
||||
databaseFetcher,
|
||||
storagePath,
|
||||
cliServer,
|
||||
commandManager,
|
||||
|
||||
@@ -16,6 +16,7 @@ import * as githubDatabasesApi from "../../../../../src/databases/github-databas
|
||||
import * as githubDatabasesDownload from "../../../../../src/databases/github-databases/download";
|
||||
import * as githubDatabasesUpdates from "../../../../../src/databases/github-databases/updates";
|
||||
import type { DatabaseUpdate } from "../../../../../src/databases/github-databases/updates";
|
||||
import { DatabaseFetcher } from "../../../../../src/databases/database-fetcher";
|
||||
|
||||
describe("GitHubDatabasesModule", () => {
|
||||
describe("promptGitHubRepositoryDownload", () => {
|
||||
@@ -23,6 +24,7 @@ describe("GitHubDatabasesModule", () => {
|
||||
let databaseManager: DatabaseManager;
|
||||
let databaseStoragePath: string;
|
||||
let cliServer: CodeQLCliServer;
|
||||
let databaseFetcher: DatabaseFetcher;
|
||||
let config: GitHubDatabaseConfig;
|
||||
let gitHubDatabasesModule: GitHubDatabasesModule;
|
||||
|
||||
@@ -66,6 +68,7 @@ describe("GitHubDatabasesModule", () => {
|
||||
databaseManager = mockEmptyDatabaseManager();
|
||||
databaseStoragePath = "/a/b/some-path";
|
||||
cliServer = mockedObject<CodeQLCliServer>({});
|
||||
databaseFetcher = new DatabaseFetcher();
|
||||
config = mockedObject<GitHubDatabaseConfig>({
|
||||
download: "ask",
|
||||
update: "ask",
|
||||
@@ -74,6 +77,7 @@ describe("GitHubDatabasesModule", () => {
|
||||
gitHubDatabasesModule = new GitHubDatabasesModule(
|
||||
app,
|
||||
databaseManager,
|
||||
databaseFetcher,
|
||||
databaseStoragePath,
|
||||
cliServer,
|
||||
config,
|
||||
@@ -124,6 +128,7 @@ describe("GitHubDatabasesModule", () => {
|
||||
gitHubDatabasesModule = new GitHubDatabasesModule(
|
||||
app,
|
||||
databaseManager,
|
||||
databaseFetcher,
|
||||
databaseStoragePath,
|
||||
cliServer,
|
||||
config,
|
||||
@@ -207,6 +212,7 @@ describe("GitHubDatabasesModule", () => {
|
||||
repo,
|
||||
databases,
|
||||
databaseManager,
|
||||
databaseFetcher,
|
||||
databaseStoragePath,
|
||||
cliServer,
|
||||
app.commands,
|
||||
@@ -250,6 +256,7 @@ describe("GitHubDatabasesModule", () => {
|
||||
repo,
|
||||
databaseUpdates,
|
||||
databaseManager,
|
||||
databaseFetcher,
|
||||
databaseStoragePath,
|
||||
cliServer,
|
||||
app.commands,
|
||||
|
||||
@@ -12,7 +12,7 @@ import type { DatabaseManager } from "../../../../../src/databases/local-databas
|
||||
import type { GitHubDatabaseConfig } from "../../../../../src/config";
|
||||
import type { CodeQLCliServer } from "../../../../../src/codeql-cli/cli";
|
||||
import { createMockCommandManager } from "../../../../__mocks__/commandsMock";
|
||||
import * as databaseFetcher from "../../../../../src/databases/database-fetcher";
|
||||
import { DatabaseFetcher } from "../../../../../src/databases/database-fetcher";
|
||||
import * as dialog from "../../../../../src/common/vscode/dialog";
|
||||
import type { DatabaseUpdate } from "../../../../../src/databases/github-databases/updates";
|
||||
import {
|
||||
@@ -344,6 +344,7 @@ describe("downloadDatabaseUpdateFromGitHub", () => {
|
||||
const owner = "github";
|
||||
const repo = "codeql";
|
||||
let databaseManager: DatabaseManager;
|
||||
let databaseFetcher: DatabaseFetcher;
|
||||
const storagePath = "/a/b/c/d";
|
||||
let cliServer: CodeQLCliServer;
|
||||
const commandManager = createMockCommandManager();
|
||||
@@ -368,7 +369,7 @@ describe("downloadDatabaseUpdateFromGitHub", () => {
|
||||
|
||||
let showQuickPickSpy: jest.SpiedFunction<typeof window.showQuickPick>;
|
||||
let downloadGitHubDatabaseFromUrlSpy: jest.SpiedFunction<
|
||||
typeof databaseFetcher.downloadGitHubDatabaseFromUrl
|
||||
DatabaseFetcher["downloadGitHubDatabaseFromUrl"]
|
||||
>;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -376,6 +377,7 @@ describe("downloadDatabaseUpdateFromGitHub", () => {
|
||||
databaseManager = mockedObject<DatabaseManager>({
|
||||
currentDatabaseItem: mockDatabaseItem(),
|
||||
});
|
||||
databaseFetcher = new DatabaseFetcher();
|
||||
cliServer = mockedObject<CodeQLCliServer>({});
|
||||
|
||||
showQuickPickSpy = jest.spyOn(window, "showQuickPick").mockResolvedValue(
|
||||
@@ -397,6 +399,7 @@ describe("downloadDatabaseUpdateFromGitHub", () => {
|
||||
repo,
|
||||
updates,
|
||||
databaseManager,
|
||||
databaseFetcher,
|
||||
storagePath,
|
||||
cliServer,
|
||||
commandManager,
|
||||
@@ -476,6 +479,7 @@ describe("downloadDatabaseUpdateFromGitHub", () => {
|
||||
repo,
|
||||
updates,
|
||||
databaseManager,
|
||||
databaseFetcher,
|
||||
storagePath,
|
||||
cliServer,
|
||||
commandManager,
|
||||
@@ -532,6 +536,7 @@ describe("downloadDatabaseUpdateFromGitHub", () => {
|
||||
repo,
|
||||
updates,
|
||||
databaseManager,
|
||||
databaseFetcher,
|
||||
storagePath,
|
||||
cliServer,
|
||||
commandManager,
|
||||
@@ -597,6 +602,7 @@ describe("downloadDatabaseUpdateFromGitHub", () => {
|
||||
repo,
|
||||
updates,
|
||||
databaseManager,
|
||||
databaseFetcher,
|
||||
storagePath,
|
||||
cliServer,
|
||||
commandManager,
|
||||
|
||||
Reference in New Issue
Block a user