Skip to content

Commit 67a6ab5

Browse files
committed
Test that we only download results once per repo
To make us confident that we're not repeatedly downloading results.
1 parent 64994d7 commit 67a6ab5

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

extensions/ql-vscode/src/vscode-tests/cli-integration/remote-queries/variant-analysis-monitor.test.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as sinon from 'sinon';
22
import { expect } from 'chai';
3-
import { CancellationTokenSource, extensions } from 'vscode';
3+
import { CancellationTokenSource, commands, extensions } from 'vscode';
44
import { CodeQLExtensionInterface } from '../../../extension';
55
import { logger } from '../../../logging';
66
import * as config from '../../../config';
@@ -115,7 +115,7 @@ describe('Variant Analysis Monitor', async function() {
115115

116116
describe('when there are successfully scanned repos', async () => {
117117
beforeEach(async function() {
118-
scannedRepos = createMockScannedRepos(['pending', 'in_progress', 'succeeded']);
118+
scannedRepos = createMockScannedRepos(['pending', 'pending', 'in_progress', 'in_progress', 'succeeded', 'succeeded', 'succeeded']);
119119
mockApiResponse = createMockApiResponse('completed', scannedRepos);
120120
mockGetVariantAnalysis = sandbox.stub(ghApiClient, 'getVariantAnalysis').resolves(mockApiResponse);
121121
});
@@ -127,6 +127,21 @@ describe('Variant Analysis Monitor', async function() {
127127
expect(result.status).to.equal('CompletedSuccessfully');
128128
expect(result.scannedReposDownloaded).to.eql(scannedRepoIds);
129129
});
130+
131+
it('should trigger a download extension command for each repo', async () => {
132+
const succeededRepos = scannedRepos.filter(r => r.analysis_status === 'succeeded');
133+
const commandSpy = sandbox.spy(commands, 'executeCommand');
134+
135+
await variantAnalysisMonitor.monitorVariantAnalysis(variantAnalysis, cancellationTokenSource.token);
136+
137+
expect(commandSpy).to.have.callCount(succeededRepos.length);
138+
139+
succeededRepos.forEach((succeededRepo, index) => {
140+
expect(commandSpy.getCall(index).args[0]).to.eq('codeQL.autoDownloadVariantAnalysisResult');
141+
expect(commandSpy.getCall(index).args[1]).to.eq(succeededRepo);
142+
expect(commandSpy.getCall(index).args[2]).to.eq(mockApiResponse);
143+
});
144+
});
130145
});
131146

132147
describe('when there are only in progress repos', async () => {

0 commit comments

Comments
 (0)