@@ -9,7 +9,7 @@ import { registerQueryHistoryScrubber } from '../../query-history-scrubber';
99import { QueryHistoryManager , HistoryTreeDataProvider , SortOrder } from '../../query-history' ;
1010import { QueryEvaluationInfo , QueryWithResults } from '../../run-queries-shared' ;
1111import { QueryHistoryConfig , QueryHistoryConfigListener } from '../../config' ;
12- import { LocalQueryInfo , InitialQueryInfo } from '../../query-results' ;
12+ import { LocalQueryInfo } from '../../query-results' ;
1313import { DatabaseManager } from '../../databases' ;
1414import * as tmp from 'tmp-promise' ;
1515import { ONE_DAY_IN_MS , ONE_HOUR_IN_MS , TWO_HOURS_IN_MS , THREE_HOURS_IN_MS } from '../../pure/time' ;
@@ -23,6 +23,7 @@ import { QueryRunner } from '../../queryRunner';
2323import { QueryResultType } from '../../pure/legacy-messages' ;
2424import { VariantAnalysisManager } from '../../remote-queries/variant-analysis-manager' ;
2525import { QueryHistoryInfo } from '../../query-history-info' ;
26+ import { createMockLocalQuery } from '../factories/local-queries/local-query-history-item' ;
2627
2728describe ( 'query-history' , ( ) => {
2829 const mockExtensionLocation = path . join ( tmpDir . name , 'mock-extension-location' ) ;
@@ -128,10 +129,10 @@ describe('query-history', () => {
128129
129130 beforeEach ( ( ) => {
130131 localQueryHistory = [
131- createMockFullQueryInfo ( 'a' , createMockQueryWithResults ( true ) ) ,
132- createMockFullQueryInfo ( 'b' , createMockQueryWithResults ( true ) ) ,
133- createMockFullQueryInfo ( 'a' , createMockQueryWithResults ( false ) ) ,
134- createMockFullQueryInfo ( 'a' , createMockQueryWithResults ( true ) ) ,
132+ createMockLocalQuery ( 'a' , createMockQueryWithResults ( true ) ) ,
133+ createMockLocalQuery ( 'b' , createMockQueryWithResults ( true ) ) ,
134+ createMockLocalQuery ( 'a' , createMockQueryWithResults ( false ) ) ,
135+ createMockLocalQuery ( 'a' , createMockQueryWithResults ( true ) ) ,
135136 ] ;
136137 allHistory = [ ...localQueryHistory ] ;
137138 } ) ;
@@ -174,7 +175,7 @@ describe('query-history', () => {
174175 it ( 'should throw an error when a query is not successful' , async ( ) => {
175176 const thisQuery = allHistory [ 3 ] ;
176177 queryHistoryManager = await createMockQueryHistory ( allHistory ) ;
177- allHistory [ 0 ] = createMockFullQueryInfo ( 'a' , createMockQueryWithResults ( false ) ) ;
178+ allHistory [ 0 ] = createMockLocalQuery ( 'a' , createMockQueryWithResults ( false ) ) ;
178179
179180 try {
180181 await ( queryHistoryManager as any ) . findOtherQueryToCompare ( thisQuery , [ thisQuery , allHistory [ 0 ] ] ) ;
@@ -356,7 +357,7 @@ describe('query-history', () => {
356357
357358
358359 it ( 'should get a tree item with raw results' , async ( ) => {
359- const mockQuery = createMockFullQueryInfo ( 'a' , createMockQueryWithResults ( true , /* raw results */ false ) ) ;
360+ const mockQuery = createMockLocalQuery ( 'a' , createMockQueryWithResults ( true , /* raw results */ false ) ) ;
360361 const treeItem = await historyTreeDataProvider . getTreeItem ( mockQuery ) ;
361362 expect ( treeItem . command ) . to . deep . eq ( {
362363 title : 'Query History Item' ,
@@ -370,34 +371,34 @@ describe('query-history', () => {
370371 } ) ;
371372
372373 it ( 'should get a tree item with interpreted results' , async ( ) => {
373- const mockQuery = createMockFullQueryInfo ( 'a' , createMockQueryWithResults ( true , /* interpreted results */ true ) ) ;
374+ const mockQuery = createMockLocalQuery ( 'a' , createMockQueryWithResults ( true , /* interpreted results */ true ) ) ;
374375 const treeItem = await historyTreeDataProvider . getTreeItem ( mockQuery ) ;
375376 expect ( treeItem . contextValue ) . to . eq ( 'interpretedResultsItem' ) ;
376377 expect ( treeItem . iconPath ) . to . deep . eq ( vscode . Uri . file ( mockExtensionLocation + '/media/drive.svg' ) . fsPath ) ;
377378 } ) ;
378379
379380 it ( 'should get a tree item that did not complete successfully' , async ( ) => {
380- const mockQuery = createMockFullQueryInfo ( 'a' , createMockQueryWithResults ( false ) , false ) ;
381+ const mockQuery = createMockLocalQuery ( 'a' , createMockQueryWithResults ( false ) , false ) ;
381382 const treeItem = await historyTreeDataProvider . getTreeItem ( mockQuery ) ;
382383 expect ( treeItem . iconPath ) . to . eq ( vscode . Uri . file ( mockExtensionLocation + '/media/red-x.svg' ) . fsPath ) ;
383384 } ) ;
384385
385386 it ( 'should get a tree item that failed before creating any results' , async ( ) => {
386- const mockQuery = createMockFullQueryInfo ( 'a' , undefined , true ) ;
387+ const mockQuery = createMockLocalQuery ( 'a' , undefined , true ) ;
387388 const treeItem = await historyTreeDataProvider . getTreeItem ( mockQuery ) ;
388389 expect ( treeItem . iconPath ) . to . eq ( vscode . Uri . file ( mockExtensionLocation + '/media/red-x.svg' ) . fsPath ) ;
389390 } ) ;
390391
391392 it ( 'should get a tree item that is in progress' , async ( ) => {
392- const mockQuery = createMockFullQueryInfo ( 'a' ) ;
393+ const mockQuery = createMockLocalQuery ( 'a' ) ;
393394 const treeItem = await historyTreeDataProvider . getTreeItem ( mockQuery ) ;
394395 expect ( treeItem . iconPath ) . to . deep . eq ( {
395396 id : 'sync~spin' , color : undefined
396397 } ) ;
397398 } ) ;
398399
399400 it ( 'should get children' , ( ) => {
400- const mockQuery = createMockFullQueryInfo ( ) ;
401+ const mockQuery = createMockLocalQuery ( ) ;
401402 historyTreeDataProvider . allHistory . push ( mockQuery ) ;
402403 expect ( historyTreeDataProvider . getChildren ( ) ) . to . deep . eq ( [ mockQuery ] ) ;
403404 expect ( historyTreeDataProvider . getChildren ( mockQuery ) ) . to . deep . eq ( [ ] ) ;
@@ -596,27 +597,6 @@ describe('query-history', () => {
596597 }
597598 } ) ;
598599
599- function createMockFullQueryInfo ( dbName = 'a' , queryWithResults ?: QueryWithResults , isFail = false ) : LocalQueryInfo {
600- const fqi = new LocalQueryInfo (
601- {
602- databaseInfo : { name : dbName } ,
603- start : new Date ( ) ,
604- queryPath : 'hucairz'
605- } as InitialQueryInfo ,
606- {
607- dispose : ( ) => { /**/ } ,
608- } as vscode . CancellationTokenSource
609- ) ;
610-
611- if ( queryWithResults ) {
612- fqi . completeThisQuery ( queryWithResults ) ;
613- }
614- if ( isFail ) {
615- fqi . failureReason = 'failure reason' ;
616- }
617- return fqi ;
618- }
619-
620600 describe ( 'query history scrubber' , ( ) => {
621601 let clock : sinon . SinonFakeTimers ;
622602 let deregister : vscode . Disposable | undefined ;
0 commit comments