@@ -20,7 +20,7 @@ import {
2020import { testDisposeHandler } from "../../test-dispose-handler" ;
2121import { QueryRunner } from "../../../../src/query-server/query-runner" ;
2222import * as dialog from "../../../../src/common/vscode/dialog" ;
23- import { Setting } from "../../../../src/config" ;
23+ import * as config from "../../../../src/config" ;
2424import { QlPackGenerator } from "../../../../src/local-queries/qlpack-generator" ;
2525import { mockedObject } from "../../utils/mocking.helpers" ;
2626import { createMockApp } from "../../../__mocks__/appMock" ;
@@ -626,7 +626,10 @@ describe("local databases", () => {
626626 showNeverAskAgainDialogSpy = jest
627627 . spyOn ( dialog , "showNeverAskAgainDialog" )
628628 . mockResolvedValue ( "No, and never ask me again" ) ;
629- const updateValueSpy = jest . spyOn ( Setting . prototype , "updateValue" ) ;
629+ const updateValueSpy = jest . spyOn (
630+ config . Setting . prototype ,
631+ "updateValue" ,
632+ ) ;
630633
631634 await ( databaseManager as any ) . createSkeletonPacks ( mockDbItem ) ;
632635
@@ -726,7 +729,17 @@ describe("local databases", () => {
726729 expect ( setCurrentDatabaseItemSpy ) . toBeCalledTimes ( 1 ) ;
727730 } ) ;
728731
729- it ( "should add database source archive folder" , async ( ) => {
732+ it ( "should not add database source archive folder when `codeQL.databaseDownload.addDatabaseSourceToWorkspace` is `false`" , async ( ) => {
733+ jest . spyOn ( config , "addDatabaseSourceToWorkspace" ) . mockReturnValue ( false ) ;
734+
735+ await databaseManager . openDatabase ( mockDbItem . databaseUri ) ;
736+
737+ expect ( addDatabaseSourceArchiveFolderSpy ) . toBeCalledTimes ( 0 ) ;
738+ } ) ;
739+
740+ it ( "should add database source archive folder when `codeQL.databaseDownload.addDatabaseSourceToWorkspace` is `true`" , async ( ) => {
741+ jest . spyOn ( config , "addDatabaseSourceToWorkspace" ) . mockReturnValue ( true ) ;
742+
730743 await databaseManager . openDatabase ( mockDbItem . databaseUri ) ;
731744
732745 expect ( addDatabaseSourceArchiveFolderSpy ) . toBeCalledTimes ( 1 ) ;
@@ -735,7 +748,9 @@ describe("local databases", () => {
735748 describe ( "when codeQL.codespacesTemplate is set to true" , ( ) => {
736749 describe ( "when we add the tutorial database to the codespace" , ( ) => {
737750 it ( "should not offer to create a skeleton QL pack" , async ( ) => {
738- jest . spyOn ( Setting . prototype , "getValue" ) . mockReturnValue ( true ) ;
751+ jest
752+ . spyOn ( config . Setting . prototype , "getValue" )
753+ . mockReturnValue ( true ) ;
739754
740755 const isTutorialDatabase = true ;
741756 const makeSelected = true ;
@@ -754,7 +769,9 @@ describe("local databases", () => {
754769
755770 describe ( "when we add a new database that isn't the tutorial one" , ( ) => {
756771 it ( "should create a skeleton QL pack" , async ( ) => {
757- jest . spyOn ( Setting . prototype , "getValue" ) . mockReturnValue ( true ) ;
772+ jest
773+ . spyOn ( config . Setting . prototype , "getValue" )
774+ . mockReturnValue ( true ) ;
758775
759776 await databaseManager . openDatabase ( mockDbItem . databaseUri ) ;
760777
@@ -765,7 +782,7 @@ describe("local databases", () => {
765782
766783 describe ( "when codeQL.codespacesTemplate is set to false" , ( ) => {
767784 it ( "should not create a skeleton QL pack" , async ( ) => {
768- jest . spyOn ( Setting . prototype , "getValue" ) . mockReturnValue ( false ) ;
785+ jest . spyOn ( config . Setting . prototype , "getValue" ) . mockReturnValue ( false ) ;
769786
770787 await databaseManager . openDatabase ( mockDbItem . databaseUri ) ;
771788 expect ( createSkeletonPacksSpy ) . toBeCalledTimes ( 0 ) ;
@@ -774,7 +791,9 @@ describe("local databases", () => {
774791
775792 describe ( "when codeQL.codespacesTemplate is not set" , ( ) => {
776793 it ( "should not create a skeleton QL pack" , async ( ) => {
777- jest . spyOn ( Setting . prototype , "getValue" ) . mockReturnValue ( undefined ) ;
794+ jest
795+ . spyOn ( config . Setting . prototype , "getValue" )
796+ . mockReturnValue ( undefined ) ;
778797
779798 await databaseManager . openDatabase ( mockDbItem . databaseUri ) ;
780799 expect ( createSkeletonPacksSpy ) . toBeCalledTimes ( 0 ) ;
0 commit comments