@@ -7,10 +7,12 @@ import * as config from '../../../config';
77import * as ghApiClient from '../../../remote-queries/gh-api/gh-api-client' ;
88import { Credentials } from '../../../authentication' ;
99import * as fs from 'fs-extra' ;
10+ import * as path from 'path' ;
1011
1112import { VariantAnalysisManager } from '../../../remote-queries/variant-analysis-manager' ;
1213import {
1314 VariantAnalysis as VariantAnalysisApiResponse ,
15+ VariantAnalysisRepoTask ,
1416 VariantAnalysisScannedRepository as ApiVariantAnalysisScannedRepository
1517} from '../../../remote-queries/gh-api/variant-analysis' ;
1618import { createMockApiResponse } from '../../factories/remote-queries/gh-api/variant-analysis-api-response' ;
@@ -72,6 +74,7 @@ describe('Variant Analysis Manager', async function() {
7274
7375 describe ( 'when credentials are valid' , async ( ) => {
7476 let getOctokitStub : sinon . SinonStub ;
77+ let arrayBuffer : ArrayBuffer ;
7578
7679 beforeEach ( async ( ) => {
7780 const mockCredentials = {
@@ -80,16 +83,18 @@ describe('Variant Analysis Manager', async function() {
8083 } )
8184 } as unknown as Credentials ;
8285 sandbox . stub ( Credentials , 'initialize' ) . resolves ( mockCredentials ) ;
86+
87+ const sourceFilePath = path . join ( __dirname , '../../../../src/vscode-tests/cli-integration/data/variant-analysis-results.zip' ) ;
88+ arrayBuffer = fs . readFileSync ( sourceFilePath ) . buffer ;
8389 } ) ;
8490
8591 describe ( 'when the artifact_url is missing' , async ( ) => {
8692 beforeEach ( async ( ) => {
8793 const dummyRepoTask = createMockVariantAnalysisRepoTask ( ) ;
8894 delete dummyRepoTask . artifact_url ;
89- getVariantAnalysisRepoStub = sandbox . stub ( ghApiClient , 'getVariantAnalysisRepo' ) . resolves ( dummyRepoTask ) ;
9095
91- const dummyResult = 'this-is-a-repo-result' ;
92- getVariantAnalysisRepoResultStub = sandbox . stub ( ghApiClient , 'getVariantAnalysisRepoResult' ) . resolves ( dummyResult ) ;
96+ getVariantAnalysisRepoStub = sandbox . stub ( ghApiClient , 'getVariantAnalysisRepo' ) . resolves ( dummyRepoTask ) ;
97+ getVariantAnalysisRepoResultStub = sandbox . stub ( ghApiClient , 'getVariantAnalysisRepoResult' ) . resolves ( arrayBuffer ) ;
9398 } ) ;
9499
95100 it ( 'should not try to download the result' , async ( ) => {
@@ -104,12 +109,13 @@ describe('Variant Analysis Manager', async function() {
104109 } ) ;
105110
106111 describe ( 'when the artifact_url is present' , async ( ) => {
112+ let dummyRepoTask : VariantAnalysisRepoTask ;
113+
107114 beforeEach ( async ( ) => {
108- const dummyRepoTask = createMockVariantAnalysisRepoTask ( ) ;
109- getVariantAnalysisRepoStub = sandbox . stub ( ghApiClient , 'getVariantAnalysisRepo' ) . resolves ( dummyRepoTask ) ;
115+ dummyRepoTask = createMockVariantAnalysisRepoTask ( ) ;
110116
111- const dummyResult = 'this-is-a-repo-result' ;
112- getVariantAnalysisRepoResultStub = sandbox . stub ( ghApiClient , 'getVariantAnalysisRepoResult' ) . resolves ( dummyResult ) ;
117+ getVariantAnalysisRepoStub = sandbox . stub ( ghApiClient , 'getVariantAnalysisRepo' ) . resolves ( dummyRepoTask ) ;
118+ getVariantAnalysisRepoResultStub = sandbox . stub ( ghApiClient , 'getVariantAnalysisRepoResult' ) . resolves ( arrayBuffer ) ;
113119 } ) ;
114120
115121 it ( 'should return early if variant analysis is cancelled' , async ( ) => {
@@ -143,16 +149,6 @@ describe('Variant Analysis Manager', async function() {
143149
144150 expect ( getVariantAnalysisRepoResultStub . calledOnce ) . to . be . true ;
145151 } ) ;
146-
147- it ( 'should save the result to disk' , async ( ) => {
148- await variantAnalysisManager . autoDownloadVariantAnalysisResult (
149- scannedRepos [ 0 ] ,
150- variantAnalysis ,
151- cancellationTokenSource . token
152- ) ;
153-
154- expect ( getVariantAnalysisRepoResultStub . calledOnce ) . to . be . true ;
155- } ) ;
156152 } ) ;
157153 } ) ;
158154} ) ;
0 commit comments