Remove unnecessary checks
This commit is contained in:
@@ -36,13 +36,7 @@ describe("DatabaseFetcher", () => {
|
||||
jest.spyOn(window, "showInformationMessage").mockResolvedValue(undefined);
|
||||
|
||||
const extension = await getActivatedExtension();
|
||||
if ("databaseManager" in extension) {
|
||||
databaseManager = extension.databaseManager;
|
||||
} else {
|
||||
throw new Error(
|
||||
"Extension not initialized. Make sure cli is downloaded and installed properly.",
|
||||
);
|
||||
}
|
||||
databaseManager = extension.databaseManager;
|
||||
|
||||
await cleanDatabases(databaseManager);
|
||||
});
|
||||
|
||||
@@ -14,13 +14,7 @@ describe("helpers (with CLI)", () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
const extension = await getActivatedExtension();
|
||||
if ("cliServer" in extension) {
|
||||
cli = extension.cliServer;
|
||||
} else {
|
||||
throw new Error(
|
||||
"Extension not initialized. Make sure cli is downloaded and installed properly.",
|
||||
);
|
||||
}
|
||||
cli = extension.cliServer;
|
||||
});
|
||||
|
||||
it("should get query metadata when available", async () => {
|
||||
|
||||
@@ -112,36 +112,29 @@ describeWithCodeQL()("using the legacy query server", () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const extension = await getActivatedExtension();
|
||||
if ("cliServer" in extension) {
|
||||
cliServer = extension.cliServer;
|
||||
cliServer.quiet = true;
|
||||
cliServer = extension.cliServer;
|
||||
cliServer.quiet = true;
|
||||
|
||||
qs = new QueryServerClient(
|
||||
createMockApp({}),
|
||||
{
|
||||
codeQlPath:
|
||||
(await extension.distributionManager.getCodeQlPathWithoutVersionCheck()) ||
|
||||
"",
|
||||
debug: false,
|
||||
cacheSize: 0,
|
||||
numThreads: 1,
|
||||
saveCache: false,
|
||||
timeoutSecs: 0,
|
||||
},
|
||||
cliServer,
|
||||
{
|
||||
contextStoragePath: tmpDir.name,
|
||||
logger: extLogger,
|
||||
},
|
||||
(task) =>
|
||||
task(nullProgressReporter, new CancellationTokenSource().token),
|
||||
);
|
||||
await qs.startQueryServer();
|
||||
} else {
|
||||
throw new Error(
|
||||
"Extension not initialized. Make sure cli is downloaded and installed properly.",
|
||||
);
|
||||
}
|
||||
qs = new QueryServerClient(
|
||||
createMockApp({}),
|
||||
{
|
||||
codeQlPath:
|
||||
(await extension.distributionManager.getCodeQlPathWithoutVersionCheck()) ||
|
||||
"",
|
||||
debug: false,
|
||||
cacheSize: 0,
|
||||
numThreads: 1,
|
||||
saveCache: false,
|
||||
timeoutSecs: 0,
|
||||
},
|
||||
cliServer,
|
||||
{
|
||||
contextStoragePath: tmpDir.name,
|
||||
logger: extLogger,
|
||||
},
|
||||
(task) => task(nullProgressReporter, new CancellationTokenSource().token),
|
||||
);
|
||||
await qs.startQueryServer();
|
||||
});
|
||||
|
||||
for (const queryTestCase of queryTestCases) {
|
||||
|
||||
@@ -115,58 +115,51 @@ describeWithCodeQL()("using the new query server", () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const extension = await getActivatedExtension();
|
||||
if ("cliServer" in extension && "databaseManager" in extension) {
|
||||
cliServer = extension.cliServer;
|
||||
cliServer = extension.cliServer;
|
||||
|
||||
cliServer.quiet = true;
|
||||
if (!(await cliServer.cliConstraints.supportsNewQueryServerForTests())) {
|
||||
supportNewQueryServer = false;
|
||||
}
|
||||
qs = new QueryServerClient(
|
||||
{
|
||||
codeQlPath:
|
||||
(await extension.distributionManager.getCodeQlPathWithoutVersionCheck()) ||
|
||||
"",
|
||||
debug: false,
|
||||
cacheSize: 0,
|
||||
numThreads: 1,
|
||||
saveCache: false,
|
||||
timeoutSecs: 0,
|
||||
},
|
||||
cliServer,
|
||||
{
|
||||
contextStoragePath: tmpDir.name,
|
||||
logger: extLogger,
|
||||
},
|
||||
(task) =>
|
||||
task(nullProgressReporter, new CancellationTokenSource().token),
|
||||
);
|
||||
await qs.startQueryServer();
|
||||
|
||||
// Unlike the old query sevre the new one wants a database and the empty direcrtory is not valid.
|
||||
// Add a database, but make sure the database manager is empty first
|
||||
await cleanDatabases(extension.databaseManager);
|
||||
const uri = Uri.file(dbLoc);
|
||||
const maybeDbItem = await importArchiveDatabase(
|
||||
createMockCommandManager(),
|
||||
uri.toString(true),
|
||||
extension.databaseManager,
|
||||
storagePath,
|
||||
() => {
|
||||
/**ignore progress */
|
||||
},
|
||||
token,
|
||||
);
|
||||
|
||||
if (!maybeDbItem) {
|
||||
throw new Error("Could not import database");
|
||||
}
|
||||
db = maybeDbItem.databaseUri.fsPath;
|
||||
} else {
|
||||
throw new Error(
|
||||
"Extension not initialized. Make sure cli is downloaded and installed properly.",
|
||||
);
|
||||
cliServer.quiet = true;
|
||||
if (!(await cliServer.cliConstraints.supportsNewQueryServerForTests())) {
|
||||
supportNewQueryServer = false;
|
||||
}
|
||||
qs = new QueryServerClient(
|
||||
{
|
||||
codeQlPath:
|
||||
(await extension.distributionManager.getCodeQlPathWithoutVersionCheck()) ||
|
||||
"",
|
||||
debug: false,
|
||||
cacheSize: 0,
|
||||
numThreads: 1,
|
||||
saveCache: false,
|
||||
timeoutSecs: 0,
|
||||
},
|
||||
cliServer,
|
||||
{
|
||||
contextStoragePath: tmpDir.name,
|
||||
logger: extLogger,
|
||||
},
|
||||
(task) => task(nullProgressReporter, new CancellationTokenSource().token),
|
||||
);
|
||||
await qs.startQueryServer();
|
||||
|
||||
// Unlike the old query sevre the new one wants a database and the empty direcrtory is not valid.
|
||||
// Add a database, but make sure the database manager is empty first
|
||||
await cleanDatabases(extension.databaseManager);
|
||||
const uri = Uri.file(dbLoc);
|
||||
const maybeDbItem = await importArchiveDatabase(
|
||||
createMockCommandManager(),
|
||||
uri.toString(true),
|
||||
extension.databaseManager,
|
||||
storagePath,
|
||||
() => {
|
||||
/**ignore progress */
|
||||
},
|
||||
token,
|
||||
);
|
||||
|
||||
if (!maybeDbItem) {
|
||||
throw new Error("Could not import database");
|
||||
}
|
||||
db = maybeDbItem.databaseUri.fsPath;
|
||||
});
|
||||
|
||||
for (const queryTestCase of queryTestCases) {
|
||||
|
||||
@@ -42,13 +42,7 @@ describe("Packaging commands", () => {
|
||||
.mockResolvedValue(undefined);
|
||||
|
||||
const extension = await getActivatedExtension();
|
||||
if ("cliServer" in extension) {
|
||||
cli = extension.cliServer;
|
||||
} else {
|
||||
throw new Error(
|
||||
"Extension not initialized. Make sure cli is downloaded and installed properly.",
|
||||
);
|
||||
}
|
||||
cli = extension.cliServer;
|
||||
});
|
||||
|
||||
it("should download all core query packs", async () => {
|
||||
|
||||
@@ -47,21 +47,15 @@ describeWithCodeQL()("Queries", () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
const extension = await getActivatedExtension();
|
||||
if ("databaseManager" in extension) {
|
||||
databaseManager = extension.databaseManager;
|
||||
cli = extension.cliServer;
|
||||
qs = extension.qs;
|
||||
cli.quiet = true;
|
||||
ctx = extension.ctx;
|
||||
qlpackFile = `${ctx.storageUri?.fsPath}/quick-queries/qlpack.yml`;
|
||||
qlpackLockFile = `${ctx.storageUri?.fsPath}/quick-queries/codeql-pack.lock.yml`;
|
||||
oldQlpackLockFile = `${ctx.storageUri?.fsPath}/quick-queries/qlpack.lock.yml`;
|
||||
qlFile = `${ctx.storageUri?.fsPath}/quick-queries/quick-query.ql`;
|
||||
} else {
|
||||
throw new Error(
|
||||
"Extension not initialized. Make sure cli is downloaded and installed properly.",
|
||||
);
|
||||
}
|
||||
databaseManager = extension.databaseManager;
|
||||
cli = extension.cliServer;
|
||||
qs = extension.qs;
|
||||
cli.quiet = true;
|
||||
ctx = extension.ctx;
|
||||
qlpackFile = `${ctx.storageUri?.fsPath}/quick-queries/qlpack.yml`;
|
||||
qlpackLockFile = `${ctx.storageUri?.fsPath}/quick-queries/codeql-pack.lock.yml`;
|
||||
oldQlpackLockFile = `${ctx.storageUri?.fsPath}/quick-queries/qlpack.lock.yml`;
|
||||
qlFile = `${ctx.storageUri?.fsPath}/quick-queries/quick-query.ql`;
|
||||
|
||||
// Ensure we are starting from a clean slate.
|
||||
safeDel(qlFile);
|
||||
|
||||
@@ -25,14 +25,8 @@ describe("Use cli", () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
const extension = await getActivatedExtension();
|
||||
if ("cliServer" in extension) {
|
||||
cli = extension.cliServer;
|
||||
supportedLanguages = await cli.getSupportedLanguages();
|
||||
} else {
|
||||
throw new Error(
|
||||
"Extension not initialized. Make sure cli is downloaded and installed properly.",
|
||||
);
|
||||
}
|
||||
cli = extension.cliServer;
|
||||
supportedLanguages = await cli.getSupportedLanguages();
|
||||
});
|
||||
|
||||
if (process.env.CLI_VERSION && process.env.CLI_VERSION !== "nightly") {
|
||||
|
||||
Reference in New Issue
Block a user