@@ -65,16 +65,6 @@ function createTestInitConfigInputs(
6565 debugDatabaseName : "" ,
6666 repository : { owner : "github" , repo : "example" } ,
6767 tempDir : "" ,
68- codeql : createStubCodeQL ( {
69- async betterResolveLanguages ( ) {
70- return {
71- extractors : {
72- html : [ { extractor_root : "" } ] ,
73- javascript : [ { extractor_root : "" } ] ,
74- } ,
75- } ;
76- } ,
77- } ) ,
7868 workspacePath : "" ,
7969 sourceRoot : "" ,
8070 githubVersion,
@@ -99,6 +89,20 @@ function createConfigFile(inputFileContents: string, tmpDir: string): string {
9989 return configFilePath ;
10090}
10191
92+ // Returns a default CodeQL stub for tests
93+ function createDefaultTestCodeQL ( ) {
94+ return createStubCodeQL ( {
95+ async betterResolveLanguages ( ) {
96+ return {
97+ extractors : {
98+ html : [ { extractor_root : "" } ] ,
99+ javascript : [ { extractor_root : "" } ] ,
100+ } ,
101+ } ;
102+ } ,
103+ } ) ;
104+ }
105+
102106type GetContentsResponse = { content ?: string } | object [ ] ;
103107
104108function mockGetContents (
@@ -153,19 +157,19 @@ test("load empty config", async (t) => {
153157 languagesInput : languages ,
154158 repository : { owner : "github" , repo : "example" } ,
155159 tempDir,
156- codeql,
157160 logger,
158161 } ) ,
162+ codeql ,
159163 ) ;
160164
161165 const expectedConfig = await configUtils . initActionState (
162166 createTestInitConfigInputs ( {
163167 languagesInput : languages ,
164168 tempDir,
165- codeql,
166169 logger,
167170 } ) ,
168171 { } ,
172+ codeql ,
169173 ) ;
170174
171175 t . deepEqual ( config , expectedConfig ) ;
@@ -193,9 +197,9 @@ test("load code quality config", async (t) => {
193197 languagesInput : languages ,
194198 repository : { owner : "github" , repo : "example" } ,
195199 tempDir,
196- codeql,
197200 logger,
198201 } ) ,
202+ codeql ,
199203 ) ;
200204
201205 // And the config we expect it to result in
@@ -277,10 +281,10 @@ test("initActionState doesn't throw if there are queries configured in the repos
277281 languagesInput : languages ,
278282 repository : { owner : "github" , repo : "example" } ,
279283 tempDir,
280- codeql,
281284 repositoryProperties,
282285 logger,
283286 } ) ,
287+ codeql ,
284288 ) ;
285289
286290 t . deepEqual ( config , expectedConfig ) ;
@@ -313,10 +317,10 @@ test("loading a saved config produces the same config", async (t) => {
313317 createTestInitConfigInputs ( {
314318 languagesInput : "javascript,python" ,
315319 tempDir,
316- codeql,
317320 workspacePath : tempDir ,
318321 logger,
319322 } ) ,
323+ codeql ,
320324 ) ;
321325 await configUtils . saveConfig ( config1 , logger ) ;
322326
@@ -364,10 +368,10 @@ test("loading config with version mismatch throws", async (t) => {
364368 createTestInitConfigInputs ( {
365369 languagesInput : "javascript,python" ,
366370 tempDir,
367- codeql,
368371 workspacePath : tempDir ,
369372 logger,
370373 } ) ,
374+ codeql ,
371375 ) ;
372376 // initConfig does not save the config, so we do it here.
373377 await configUtils . saveConfig ( config , logger ) ;
@@ -394,6 +398,7 @@ test("load input outside of workspace", async (t) => {
394398 tempDir,
395399 workspacePath : tempDir ,
396400 } ) ,
401+ createDefaultTestCodeQL ( ) ,
397402 ) ;
398403 throw new Error ( "initConfig did not throw error" ) ;
399404 } catch ( err ) {
@@ -421,6 +426,7 @@ test("load non-local input with invalid repo syntax", async (t) => {
421426 tempDir,
422427 workspacePath : tempDir ,
423428 } ) ,
429+ createDefaultTestCodeQL ( ) ,
424430 ) ;
425431 throw new Error ( "initConfig did not throw error" ) ;
426432 } catch ( err ) {
@@ -450,6 +456,7 @@ test("load non-existent input", async (t) => {
450456 tempDir,
451457 workspacePath : tempDir ,
452458 } ) ,
459+ createDefaultTestCodeQL ( ) ,
453460 ) ;
454461 throw new Error ( "initConfig did not throw error" ) ;
455462 } catch ( err ) {
@@ -534,9 +541,9 @@ test("load non-empty input", async (t) => {
534541 debugArtifactName : "my-artifact" ,
535542 debugDatabaseName : "my-db" ,
536543 tempDir,
537- codeql,
538544 workspacePath : tempDir ,
539545 } ) ,
546+ codeql ,
540547 ) ;
541548
542549 // Should exactly equal the object we constructed earlier
@@ -588,9 +595,9 @@ test("Using config input and file together, config input should be used.", async
588595 configFile : configFilePath ,
589596 configInput,
590597 tempDir,
591- codeql,
592598 workspacePath : tempDir ,
593599 } ) ,
600+ codeql ,
594601 ) ;
595602
596603 t . deepEqual ( config . originalUserInput , yaml . load ( configInput ) ) ;
@@ -637,9 +644,9 @@ test("API client used when reading remote config", async (t) => {
637644 languagesInput,
638645 configFile,
639646 tempDir,
640- codeql,
641647 workspacePath : tempDir ,
642648 } ) ,
649+ codeql ,
643650 ) ;
644651 t . assert ( spyGetContents . called ) ;
645652 } ) ;
@@ -658,6 +665,7 @@ test("Remote config handles the case where a directory is provided", async (t) =
658665 tempDir,
659666 workspacePath : tempDir ,
660667 } ) ,
668+ createDefaultTestCodeQL ( ) ,
661669 ) ;
662670 throw new Error ( "initConfig did not throw error" ) ;
663671 } catch ( err ) {
@@ -686,6 +694,7 @@ test("Invalid format of remote config handled correctly", async (t) => {
686694 tempDir,
687695 workspacePath : tempDir ,
688696 } ) ,
697+ createDefaultTestCodeQL ( ) ,
689698 ) ;
690699 throw new Error ( "initConfig did not throw error" ) ;
691700 } catch ( err ) {
@@ -712,9 +721,9 @@ test("No detected languages", async (t) => {
712721 await configUtils . initConfig (
713722 createTestInitConfigInputs ( {
714723 tempDir,
715- codeql,
716724 workspacePath : tempDir ,
717725 } ) ,
726+ codeql ,
718727 ) ;
719728 throw new Error ( "initConfig did not throw error" ) ;
720729 } catch ( err ) {
@@ -737,6 +746,7 @@ test("Unknown languages", async (t) => {
737746 tempDir,
738747 workspacePath : tempDir ,
739748 } ) ,
749+ createDefaultTestCodeQL ( ) ,
740750 ) ;
741751 throw new Error ( "initConfig did not throw error" ) ;
742752 } catch ( err ) {
0 commit comments