Skip to content

Commit d6ccc11

Browse files
committed
Update tests to check we call the generator
We don't need to repeat the tests for the generator functionality here. All we want to check is that the generator is triggered correctly.
1 parent 24eb8fd commit d6ccc11

File tree

1 file changed

+5
-25
lines changed

1 file changed

+5
-25
lines changed

extensions/ql-vscode/test/vscode-tests/minimal-workspace/databases.test.ts

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,8 @@ describe("databases", () => {
593593

594594
describe("createSkeletonPacks", () => {
595595
let mockDbItem: DatabaseItemImpl;
596-
let packfolderName: string;
597-
let qlPackYamlFilePath: string;
598-
let exampleQlFilePath: string;
599596
let language: string;
597+
let generateSpy: jest.SpyInstance;
600598

601599
beforeEach(() => {
602600
language = "ruby";
@@ -608,17 +606,9 @@ describe("databases", () => {
608606
};
609607
mockDbItem = createMockDB(options);
610608

611-
packfolderName = `codeql-custom-queries-${mockDbItem.language}`;
612-
qlPackYamlFilePath = join(packfolderName, "qlpack.yml");
613-
exampleQlFilePath = join(packfolderName, "example.ql");
614-
});
615-
616-
afterEach(async () => {
617-
try {
618-
fs.rmdirSync(packfolderName, { recursive: true });
619-
} catch (e) {
620-
// ignore
621-
}
609+
generateSpy = jest
610+
.spyOn(QlPackGenerator.prototype, "generate")
611+
.mockImplementation(() => Promise.resolve());
622612
});
623613

624614
describe("when the language is set", () => {
@@ -633,25 +623,15 @@ describe("databases", () => {
633623
.spyOn(helpers, "showBinaryChoiceDialog")
634624
.mockResolvedValue(false);
635625

636-
const generateSpy = jest.spyOn(QlPackGenerator.prototype, "generate");
637-
638626
await (databaseManager as any).createSkeletonPacks(mockDbItem);
639627

640628
expect(generateSpy).not.toBeCalled();
641629
});
642630

643631
it("should create the skeleton QL pack for the user", async () => {
644-
expect(fs.existsSync(packfolderName)).toBe(false);
645-
expect(fs.existsSync(qlPackYamlFilePath)).toBe(false);
646-
expect(fs.existsSync(exampleQlFilePath)).toBe(false);
647-
648632
await (databaseManager as any).createSkeletonPacks(mockDbItem);
649633

650-
expect(fs.existsSync(packfolderName)).toBe(true);
651-
expect(fs.existsSync(qlPackYamlFilePath)).toBe(true);
652-
expect(fs.existsSync(exampleQlFilePath)).toBe(true);
653-
654-
expect(packAddSpy).toHaveBeenCalledWith(packfolderName, language);
634+
expect(generateSpy).toBeCalled();
655635
});
656636
});
657637

0 commit comments

Comments
 (0)