Skip to content

Commit f47d6ec

Browse files
Stub getRepositoryFromNwoStub
1 parent 0e23dd5 commit f47d6ec

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

extensions/ql-vscode/src/vscode-tests/cli-integration/remote-queries/run-remote-query.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { UserCancellationException } from '../../../commandRunner';
1515
import * as ghApiClient from '../../../remote-queries/gh-api/gh-api-client';
1616
import { lte } from 'semver';
1717
import { VariantAnalysis } from '../../../remote-queries/gh-api/variant-analysis';
18+
import { Repository } from '../../../remote-queries/gh-api/repository';
1819

1920
describe('Remote queries', function() {
2021
const baseDir = path.join(__dirname, '../../../../src/vscode-tests/cli-integration');
@@ -29,6 +30,7 @@ describe('Remote queries', function() {
2930
let token: CancellationToken;
3031
let progress: sinon.SinonSpy;
3132
let showQuickPickSpy: sinon.SinonStub;
33+
let getRepositoryFromNwoStub: sinon.SinonStub;
3234

3335
// use `function` so we have access to `this`
3436
beforeEach(async function() {
@@ -57,6 +59,14 @@ describe('Remote queries', function() {
5759
.onFirstCall().resolves({ repositories: ['github/vscode-codeql'] } as unknown as QuickPickItem)
5860
.onSecondCall().resolves('javascript' as unknown as QuickPickItem);
5961

62+
const dummyRepository: Repository = {
63+
id: 123,
64+
name: 'vscode-codeql',
65+
full_name: 'github/vscode-codeql',
66+
private: false,
67+
};
68+
getRepositoryFromNwoStub = sandbox.stub(ghApiClient, 'getRepositoryFromNwo').resolves(dummyRepository);
69+
6070
// always run in the vscode-codeql repo
6171
await setRemoteControllerRepo('github/vscode-codeql');
6272
await setRemoteRepositoryLists({ 'vscode-codeql': ['github/vscode-codeql'] });
@@ -78,6 +88,8 @@ describe('Remote queries', function() {
7888
// to retrieve the list of repositories
7989
expect(showQuickPickSpy).to.have.been.calledOnce;
8090

91+
expect(getRepositoryFromNwoStub).to.have.been.calledOnce;
92+
8193
// check a few files that we know should exist and others that we know should not
8294

8395
// the tarball to deliver to the server
@@ -137,6 +149,8 @@ describe('Remote queries', function() {
137149
// and a second time to ask for the language
138150
expect(showQuickPickSpy).to.have.been.calledTwice;
139151

152+
expect(getRepositoryFromNwoStub).to.have.been.calledOnce;
153+
140154
// check a few files that we know should exist and others that we know should not
141155

142156
// the tarball to deliver to the server
@@ -197,6 +211,8 @@ describe('Remote queries', function() {
197211
// to retrieve the list of repositories
198212
expect(showQuickPickSpy).to.have.been.calledOnce;
199213

214+
expect(getRepositoryFromNwoStub).to.have.been.calledOnce;
215+
200216
// check a few files that we know should exist and others that we know should not
201217

202218
// the tarball to deliver to the server
@@ -293,6 +309,8 @@ describe('Remote queries', function() {
293309
const querySubmissionResult = await runRemoteQuery(cli, credentials, fileUri, true, progress, token);
294310
expect(querySubmissionResult).to.be.ok;
295311

312+
expect(getRepositoryFromNwoStub).to.have.been.calledOnce;
313+
296314
expect(submitVariantAnalysisStub).to.have.been.calledOnce;
297315
});
298316

@@ -317,6 +335,8 @@ describe('Remote queries', function() {
317335
const querySubmissionResult = await runRemoteQuery(cli, credentials, fileUri, true, progress, token);
318336
expect(querySubmissionResult).to.be.ok;
319337

338+
expect(getRepositoryFromNwoStub).to.have.been.calledOnce;
339+
320340
expect(submitVariantAnalysisStub).to.have.been.calledOnce;
321341
});
322342

@@ -341,6 +361,8 @@ describe('Remote queries', function() {
341361
const querySubmissionResult = await runRemoteQuery(cli, credentials, fileUri, true, progress, token);
342362
expect(querySubmissionResult).to.be.ok;
343363

364+
expect(getRepositoryFromNwoStub).to.have.been.calledOnce;
365+
344366
expect(submitVariantAnalysisStub).to.have.been.calledOnce;
345367
});
346368

0 commit comments

Comments
 (0)