Don't offer to create skeleton pack for default database in CodeTour

This is step 3 in the Code Tour. At this point we don't need to create
the skeleton pack so let's disable that functionality.

Co-authored-by: Shati Patel <shati-patel@github.com>
This commit is contained in:
Elena Tanasoiu
2023-02-15 11:04:16 +00:00
parent 5933f097e7
commit 397be15b89
3 changed files with 33 additions and 9 deletions

View File

@@ -379,11 +379,14 @@ export class DatabaseUI extends DisposableObject {
);
let databaseItem = this.databaseManager.findDatabaseItem(uri);
const isTutorialDatabase = true;
if (databaseItem === undefined) {
databaseItem = await this.databaseManager.openDatabase(
progress,
token,
uri,
"CodeQL Tutorial Database",
isTutorialDatabase,
);
}
await this.databaseManager.setCurrentDatabaseItem(databaseItem);

View File

@@ -606,6 +606,7 @@ export class DatabaseManager extends DisposableObject {
token: vscode.CancellationToken,
uri: vscode.Uri,
displayName?: string,
isTutorialDatabase?: boolean,
): Promise<DatabaseItem> {
const contents = await DatabaseResolver.resolveDatabaseContents(uri);
// Ignore the source archive for QLTest databases by default.
@@ -629,7 +630,7 @@ export class DatabaseManager extends DisposableObject {
await this.addDatabaseItem(progress, token, databaseItem);
await this.addDatabaseSourceArchiveFolder(databaseItem);
if (isCodespacesTemplate()) {
if (isCodespacesTemplate() && !isTutorialDatabase) {
await this.createSkeletonPacks(databaseItem);
}

View File

@@ -711,16 +711,36 @@ describe("databases", () => {
});
describe("when codeQL.codespacesTemplate is set to true", () => {
it("should create a skeleton QL pack", async () => {
jest.spyOn(Setting.prototype, "getValue").mockReturnValue(true);
describe("when we add the tutorial database to the codespace", () => {
it("should not offer to create a skeleton QL pack", async () => {
jest.spyOn(Setting.prototype, "getValue").mockReturnValue(true);
await databaseManager.openDatabase(
{} as ProgressCallback,
{} as CancellationToken,
mockDbItem.databaseUri,
);
const isTutorialDatabase = true;
expect(createSkeletonPacksSpy).toBeCalledTimes(1);
await databaseManager.openDatabase(
{} as ProgressCallback,
{} as CancellationToken,
mockDbItem.databaseUri,
"CodeQL Tutorial Database",
isTutorialDatabase,
);
expect(createSkeletonPacksSpy).toBeCalledTimes(0);
});
});
describe("when we add a new database that isn't the tutorial one", () => {
it("should create a skeleton QL pack", async () => {
jest.spyOn(Setting.prototype, "getValue").mockReturnValue(true);
await databaseManager.openDatabase(
{} as ProgressCallback,
{} as CancellationToken,
mockDbItem.databaseUri,
);
expect(createSkeletonPacksSpy).toBeCalledTimes(1);
});
});
});