Skip to content

Commit f5fbd7f

Browse files
committed
Switch tests to new types
1 parent 405292e commit f5fbd7f

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* The qlpack lock file, either in qlpack.lock.yml or in codeql-pack.lock.yml.
3+
*/
4+
export interface QlPackLockFile {
5+
lockVersion: string;
6+
dependencies?: Record<string, string>;
7+
compiled?: boolean;
8+
}

extensions/ql-vscode/test/vscode-tests/cli-integration/variant-analysis/variant-analysis-manager.test.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { QueryLanguage } from "../../../../src/common/query-language";
3232
import { readBundledPack } from "../../utils/bundled-pack-helpers";
3333
import { load } from "js-yaml";
3434
import { ExtensionPackMetadata } from "../../../../src/model-editor/extension-pack-metadata";
35+
import { QlPackLockFile } from "../../../../src/packaging/qlpack-lock-file";
3536

3637
describe("Variant Analysis Manager", () => {
3738
let cli: CodeQLCliServer;
@@ -380,9 +381,7 @@ describe("Variant Analysis Manager", () => {
380381
: "codeql-pack.yml";
381382
const qlpackContents = load(
382383
packFS.fileContents(packFileName).toString("utf-8"),
383-
) as ExtensionPackMetadata & {
384-
dependencies: Record<string, string>;
385-
};
384+
) as ExtensionPackMetadata;
386385
expect(qlpackContents.name).toEqual(expectedPackName);
387386
if (checkVersion) {
388387
expect(qlpackContents.version).toEqual("0.0.0");
@@ -396,11 +395,9 @@ describe("Variant Analysis Manager", () => {
396395
}
397396
const qlpackLockContents = load(
398397
packFS.fileContents("codeql-pack.lock.yml").toString("utf-8"),
399-
) as {
400-
dependencies: Record<string, string>;
401-
};
398+
) as QlPackLockFile;
402399

403-
const actualLockKeys = Object.keys(qlpackLockContents.dependencies);
400+
const actualLockKeys = Object.keys(qlpackLockContents.dependencies ?? {});
404401

405402
// The lock file should contain at least the specified dependencies.
406403
dependenciesToCheck.forEach((dep) =>

extensions/ql-vscode/test/vscode-tests/global.helper.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { removeWorkspaceRefs } from "../../src/variant-analysis/run-remote-query
1111
import { CodeQLExtensionInterface } from "../../src/extension";
1212
import { importArchiveDatabase } from "../../src/databases/database-fetcher";
1313
import { createMockCommandManager } from "../__mocks__/commandsMock";
14+
import { QlPackFile } from "../../src/packaging/qlpack-file";
1415

1516
// This file contains helpers shared between tests that work with an activated extension.
1617

@@ -89,9 +90,9 @@ export async function fixWorkspaceReferences(
8990
): Promise<Record<string, string> | undefined> {
9091
if (!(await cli.cliConstraints.supportsWorkspaceReferences())) {
9192
// remove the workspace references from the qlpack
92-
const qlpack = load(readFileSync(qlpackFileWithWorkspaceRefs, "utf8")) as {
93-
dependencies: Record<string, string>;
94-
};
93+
const qlpack = load(
94+
readFileSync(qlpackFileWithWorkspaceRefs, "utf8"),
95+
) as QlPackFile;
9596
const originalDeps = { ...qlpack.dependencies };
9697
removeWorkspaceRefs(qlpack);
9798
writeFileSync(qlpackFileWithWorkspaceRefs, dump(qlpack));
@@ -115,9 +116,9 @@ export async function restoreWorkspaceReferences(
115116
if (!originalDeps) {
116117
return;
117118
}
118-
const qlpack = load(readFileSync(qlpackFileWithWorkspaceRefs, "utf8")) as {
119-
dependencies: Record<string, string>;
120-
};
119+
const qlpack = load(
120+
readFileSync(qlpackFileWithWorkspaceRefs, "utf8"),
121+
) as QlPackFile;
121122
qlpack.dependencies = originalDeps;
122123
writeFileSync(qlpackFileWithWorkspaceRefs, dump(qlpack));
123124
}

0 commit comments

Comments
 (0)