Skip to content

Commit 8df061f

Browse files
authored
Merge pull request #1607 from github/aeisenberg/fix-failing-tests
`loadPersistedState` should happen outside of dbm constructor
2 parents 0354b1c + 0885a22 commit 8df061f

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

extensions/ql-vscode/src/databases.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,6 @@ export class DatabaseManager extends DisposableObject {
559559
super();
560560

561561
qs.onStart(this.reregisterDatabases.bind(this));
562-
563-
// Let this run async.
564-
void this.loadPersistedState();
565562
}
566563

567564
public async openDatabase(
@@ -691,7 +688,7 @@ export class DatabaseManager extends DisposableObject {
691688
return item;
692689
}
693690

694-
private async loadPersistedState(): Promise<void> {
691+
public async loadPersistedState(): Promise<void> {
695692
return withProgress({
696693
location: vscode.ProgressLocation.Notification
697694
},

extensions/ql-vscode/src/extension.ts

+4
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,10 @@ async function activateWithInstalledDistribution(
452452

453453
void logger.log('Initializing database manager.');
454454
const dbm = new DatabaseManager(ctx, qs, cliServer, logger);
455+
456+
// Let this run async.
457+
void dbm.loadPersistedState();
458+
455459
ctx.subscriptions.push(dbm);
456460
void logger.log('Initializing database panel.');
457461
const databaseUI = new DatabaseUI(

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ describe('databases', () => {
7777
},
7878
resolveDatabase: resolveDatabaseSpy
7979
} as unknown as CodeQLCliServer,
80-
{} as Logger,
80+
{
81+
log: () => { /**/ }
82+
} as unknown as Logger,
8183
);
8284

8385
// Unfortunately, during a test it is not possible to convert from

extensions/ql-vscode/src/vscode-tests/minimal-workspace/index.ts

+9
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,12 @@ chai.use(sinonChai);
1212
export function run(): Promise<void> {
1313
return runTestsInDirectory(__dirname);
1414
}
15+
16+
process.addListener('unhandledRejection', (reason) => {
17+
if (reason instanceof Error && reason.message === 'Canceled') {
18+
console.log('Cancellation requested after the test has ended.');
19+
process.exit(0);
20+
} else {
21+
fail(String(reason));
22+
}
23+
});

0 commit comments

Comments
 (0)