@@ -7,7 +7,6 @@ import * as sinon from 'sinon';
77import { logger } from '../../logging' ;
88import { registerQueryHistoryScrubber } from '../../query-history-scrubber' ;
99import { QueryHistoryManager , HistoryTreeDataProvider , SortOrder } from '../../query-history' ;
10- import { QueryEvaluationInfo , QueryWithResults } from '../../run-queries-shared' ;
1110import { QueryHistoryConfig , QueryHistoryConfigListener } from '../../config' ;
1211import { LocalQueryInfo } from '../../query-results' ;
1312import { DatabaseManager } from '../../databases' ;
@@ -20,10 +19,9 @@ import { RemoteQueriesManager } from '../../remote-queries/remote-queries-manage
2019import { ResultsView } from '../../interface' ;
2120import { EvalLogViewer } from '../../eval-log-viewer' ;
2221import { QueryRunner } from '../../queryRunner' ;
23- import { QueryResultType } from '../../pure/legacy-messages' ;
2422import { VariantAnalysisManager } from '../../remote-queries/variant-analysis-manager' ;
2523import { QueryHistoryInfo } from '../../query-history-info' ;
26- import { createMockLocalQuery } from '../factories/local-queries/local-query-history-item' ;
24+ import { createMockLocalQuery , createMockQueryWithResults } from '../factories/local-queries/local-query-history-item' ;
2725
2826describe ( 'query-history' , ( ) => {
2927 const mockExtensionLocation = path . join ( tmpDir . name , 'mock-extension-location' ) ;
@@ -129,10 +127,10 @@ describe('query-history', () => {
129127
130128 beforeEach ( ( ) => {
131129 localQueryHistory = [
132- createMockLocalQuery ( 'a' , createMockQueryWithResults ( true ) ) ,
133- createMockLocalQuery ( 'b' , createMockQueryWithResults ( true ) ) ,
134- createMockLocalQuery ( 'a' , createMockQueryWithResults ( false ) ) ,
135- createMockLocalQuery ( 'a' , createMockQueryWithResults ( true ) ) ,
130+ createMockLocalQuery ( 'a' , createMockQueryWithResults ( sandbox , true ) ) ,
131+ createMockLocalQuery ( 'b' , createMockQueryWithResults ( sandbox , true ) ) ,
132+ createMockLocalQuery ( 'a' , createMockQueryWithResults ( sandbox , false ) ) ,
133+ createMockLocalQuery ( 'a' , createMockQueryWithResults ( sandbox , true ) ) ,
136134 ] ;
137135 allHistory = [ ...localQueryHistory ] ;
138136 } ) ;
@@ -175,7 +173,7 @@ describe('query-history', () => {
175173 it ( 'should throw an error when a query is not successful' , async ( ) => {
176174 const thisQuery = allHistory [ 3 ] ;
177175 queryHistoryManager = await createMockQueryHistory ( allHistory ) ;
178- allHistory [ 0 ] = createMockLocalQuery ( 'a' , createMockQueryWithResults ( false ) ) ;
176+ allHistory [ 0 ] = createMockLocalQuery ( 'a' , createMockQueryWithResults ( sandbox , false ) ) ;
179177
180178 try {
181179 await ( queryHistoryManager as any ) . findOtherQueryToCompare ( thisQuery , [ thisQuery , allHistory [ 0 ] ] ) ;
@@ -357,7 +355,7 @@ describe('query-history', () => {
357355
358356
359357 it ( 'should get a tree item with raw results' , async ( ) => {
360- const mockQuery = createMockLocalQuery ( 'a' , createMockQueryWithResults ( true , /* raw results */ false ) ) ;
358+ const mockQuery = createMockLocalQuery ( 'a' , createMockQueryWithResults ( sandbox , true , /* raw results */ false ) ) ;
361359 const treeItem = await historyTreeDataProvider . getTreeItem ( mockQuery ) ;
362360 expect ( treeItem . command ) . to . deep . eq ( {
363361 title : 'Query History Item' ,
@@ -371,14 +369,14 @@ describe('query-history', () => {
371369 } ) ;
372370
373371 it ( 'should get a tree item with interpreted results' , async ( ) => {
374- const mockQuery = createMockLocalQuery ( 'a' , createMockQueryWithResults ( true , /* interpreted results */ true ) ) ;
372+ const mockQuery = createMockLocalQuery ( 'a' , createMockQueryWithResults ( sandbox , true , /* interpreted results */ true ) ) ;
375373 const treeItem = await historyTreeDataProvider . getTreeItem ( mockQuery ) ;
376374 expect ( treeItem . contextValue ) . to . eq ( 'interpretedResultsItem' ) ;
377375 expect ( treeItem . iconPath ) . to . deep . eq ( vscode . Uri . file ( mockExtensionLocation + '/media/drive.svg' ) . fsPath ) ;
378376 } ) ;
379377
380378 it ( 'should get a tree item that did not complete successfully' , async ( ) => {
381- const mockQuery = createMockLocalQuery ( 'a' , createMockQueryWithResults ( false ) , false ) ;
379+ const mockQuery = createMockLocalQuery ( 'a' , createMockQueryWithResults ( sandbox , false ) , false ) ;
382380 const treeItem = await historyTreeDataProvider . getTreeItem ( mockQuery ) ;
383381 expect ( treeItem . iconPath ) . to . eq ( vscode . Uri . file ( mockExtensionLocation + '/media/red-x.svg' ) . fsPath ) ;
384382 } ) ;
@@ -774,24 +772,6 @@ describe('query-history', () => {
774772 }
775773 } ) ;
776774
777- function createMockQueryWithResults ( didRunSuccessfully = true , hasInterpretedResults = true ) : QueryWithResults {
778- return {
779- query : {
780- hasInterpretedResults : ( ) => Promise . resolve ( hasInterpretedResults ) ,
781- deleteQuery : sandbox . stub ( ) ,
782- } as unknown as QueryEvaluationInfo ,
783- successful : didRunSuccessfully ,
784- message : 'foo' ,
785- dispose : sandbox . spy ( ) ,
786- result : {
787- evaluationTime : 1 ,
788- queryId : 0 ,
789- runId : 0 ,
790- resultType : QueryResultType . SUCCESS ,
791- }
792- } ;
793- }
794-
795775 async function createMockQueryHistory ( allHistory : QueryHistoryInfo [ ] ) {
796776 const qhm = new QueryHistoryManager (
797777 { } as QueryRunner ,
0 commit comments