@@ -15,9 +15,12 @@ import * as config from '../../../config';
1515import { UserCancellationException } from '../../../commandRunner' ;
1616import * as ghApiClient from '../../../remote-queries/gh-api/gh-api-client' ;
1717import { lte } from 'semver' ;
18- import { VariantAnalysis } from '../../../remote-queries/gh-api/variant-analysis' ;
18+ import {
19+ VariantAnalysis as VariantAnalysisApiResponse
20+ } from '../../../remote-queries/gh-api/variant-analysis' ;
1921import { Repository } from '../../../remote-queries/gh-api/repository' ;
2022import { VariantAnalysisStatus } from '../../../remote-queries/shared/variant-analysis' ;
23+ import { createMockApiResponse } from '../../factories/remote-queries/gh-api/variant-analysis-api-response' ;
2124
2225describe ( 'Remote queries' , function ( ) {
2326 const baseDir = path . join ( __dirname , '../../../../src/vscode-tests/cli-integration' ) ;
@@ -285,70 +288,52 @@ describe('Remote queries', function() {
285288 } ) ;
286289
287290 describe ( 'when live results are enabled' , ( ) => {
291+ let mockApiResponse : VariantAnalysisApiResponse ;
292+ let mockSubmitVariantAnalysis : sinon . SinonStub ;
293+
288294 beforeEach ( ( ) => {
289295 liveResultsStub . returns ( true ) ;
296+ mockApiResponse = createMockApiResponse ( 'in_progress' ) ;
297+ mockSubmitVariantAnalysis = sandbox . stub ( ghApiClient , 'submitVariantAnalysis' ) . resolves ( mockApiResponse ) ;
290298 } ) ;
291299
292- const dummyVariantAnalysis : VariantAnalysis = {
293- id : 123 ,
294- controller_repo : {
295- id : 64 ,
296- name : 'pickles' ,
297- full_name : 'github/pickles' ,
298- private : false ,
299- } ,
300- actor_id : 27 ,
301- query_language : 'javascript' ,
302- query_pack_url : 'https://example.com/foo' ,
303- status : 'in_progress' ,
304- } ;
305-
306300 it ( 'should run a variant analysis that is part of a qlpack' , async ( ) => {
307- const submitVariantAnalysisStub = sandbox . stub ( ghApiClient , 'submitVariantAnalysis' ) . resolves ( dummyVariantAnalysis ) ;
308-
309301 const fileUri = getFile ( 'data-remote-qlpack/in-pack.ql' ) ;
310302
311303 const querySubmissionResult = await runRemoteQuery ( cli , credentials , fileUri , true , progress , token ) ;
312304 expect ( querySubmissionResult ) . to . be . ok ;
313305 const variantAnalysis = querySubmissionResult ! . variantAnalysis ! ;
314- expect ( variantAnalysis . id ) . to . be . equal ( dummyVariantAnalysis . id ) ;
306+ expect ( variantAnalysis . id ) . to . be . equal ( mockApiResponse . id ) ;
315307 expect ( variantAnalysis . status ) . to . be . equal ( VariantAnalysisStatus . InProgress ) ;
316308
317309 expect ( getRepositoryFromNwoStub ) . to . have . been . calledOnce ;
318-
319- expect ( submitVariantAnalysisStub ) . to . have . been . calledOnce ;
310+ expect ( mockSubmitVariantAnalysis ) . to . have . been . calledOnce ;
320311 } ) ;
321312
322313 it ( 'should run a remote query that is not part of a qlpack' , async ( ) => {
323- const submitVariantAnalysisStub = sandbox . stub ( ghApiClient , 'submitVariantAnalysis' ) . resolves ( dummyVariantAnalysis ) ;
324-
325314 const fileUri = getFile ( 'data-remote-no-qlpack/in-pack.ql' ) ;
326315
327316 const querySubmissionResult = await runRemoteQuery ( cli , credentials , fileUri , true , progress , token ) ;
328317 expect ( querySubmissionResult ) . to . be . ok ;
329318 const variantAnalysis = querySubmissionResult ! . variantAnalysis ! ;
330- expect ( variantAnalysis . id ) . to . be . equal ( dummyVariantAnalysis . id ) ;
319+ expect ( variantAnalysis . id ) . to . be . equal ( mockApiResponse . id ) ;
331320 expect ( variantAnalysis . status ) . to . be . equal ( VariantAnalysisStatus . InProgress ) ;
332321
333322 expect ( getRepositoryFromNwoStub ) . to . have . been . calledOnce ;
334-
335- expect ( submitVariantAnalysisStub ) . to . have . been . calledOnce ;
323+ expect ( mockSubmitVariantAnalysis ) . to . have . been . calledOnce ;
336324 } ) ;
337325
338326 it ( 'should run a remote query that is nested inside a qlpack' , async ( ) => {
339- const submitVariantAnalysisStub = sandbox . stub ( ghApiClient , 'submitVariantAnalysis' ) . resolves ( dummyVariantAnalysis ) ;
340-
341327 const fileUri = getFile ( 'data-remote-qlpack-nested/subfolder/in-pack.ql' ) ;
342328
343329 const querySubmissionResult = await runRemoteQuery ( cli , credentials , fileUri , true , progress , token ) ;
344330 expect ( querySubmissionResult ) . to . be . ok ;
345331 const variantAnalysis = querySubmissionResult ! . variantAnalysis ! ;
346- expect ( variantAnalysis . id ) . to . be . equal ( dummyVariantAnalysis . id ) ;
332+ expect ( variantAnalysis . id ) . to . be . equal ( mockApiResponse . id ) ;
347333 expect ( variantAnalysis . status ) . to . be . equal ( VariantAnalysisStatus . InProgress ) ;
348334
349335 expect ( getRepositoryFromNwoStub ) . to . have . been . calledOnce ;
350-
351- expect ( submitVariantAnalysisStub ) . to . have . been . calledOnce ;
336+ expect ( mockSubmitVariantAnalysis ) . to . have . been . calledOnce ;
352337 } ) ;
353338
354339 it ( 'should cancel a run before uploading' , async ( ) => {
0 commit comments