@@ -17,6 +17,7 @@ import {
17
17
getSarifOutputType ,
18
18
QueryMetadata ,
19
19
getBqrsResultCount ,
20
+ getQueryPackInfo ,
20
21
} from "./codeql" ;
21
22
22
23
const test = anyTest as TestFn < { db : string ; tmpDir : string } > ;
@@ -50,8 +51,49 @@ test.after(async (t) => {
50
51
}
51
52
} ) ;
52
53
54
+ test ( "getting query pack info" , async ( t ) => {
55
+ const queryPackInfo = await getQueryPackInfo ( "codeql" , "testdata/test_pack" ) ;
56
+
57
+ const queries = { } ;
58
+ queries [ path . resolve ( "testdata/test_pack/x/query.ql" ) ] = {
59
+ name : "Test query" ,
60
+ description : "Test query description" ,
61
+ kind : "table" ,
62
+ id : "test/query/id" ,
63
+ } ;
64
+ t . deepEqual ( queryPackInfo , {
65
+ path : path . resolve ( "testdata/test_pack" ) ,
66
+ name : "codeql/queries" ,
67
+ queries,
68
+ } ) ;
69
+ } ) ;
70
+
71
+ test ( "getting query pack info with multiple queries" , async ( t ) => {
72
+ const queryPackInfo = await getQueryPackInfo (
73
+ "codeql" ,
74
+ "testdata/test_pack_multiple_queries" ,
75
+ ) ;
76
+
77
+ const queries = { } ;
78
+ queries [ path . resolve ( "testdata/test_pack_multiple_queries/x/query.ql" ) ] = {
79
+ name : "Test query 1" ,
80
+ kind : "table" ,
81
+ id : "test/query/one" ,
82
+ } ;
83
+ queries [ path . resolve ( "testdata/test_pack_multiple_queries/z/query.ql" ) ] = {
84
+ name : "Test query 2" ,
85
+ kind : "table" ,
86
+ id : "test/query/two" ,
87
+ } ;
88
+ t . deepEqual ( queryPackInfo , {
89
+ path : path . resolve ( "testdata/test_pack_multiple_queries" ) ,
90
+ name : "codeql/queries" ,
91
+ queries,
92
+ } ) ;
93
+ } ) ;
94
+
53
95
test ( "running a query in a pack" , async ( t ) => {
54
- const queryPack = path . resolve ( "testdata/test_pack" ) ;
96
+ const queryPack = await getQueryPackInfo ( "codeql" , "testdata/test_pack" ) ;
55
97
const tmpDir = fs . mkdtempSync ( "tmp" ) ;
56
98
const cwd = process . cwd ( ) ;
57
99
process . chdir ( tmpDir ) ;
@@ -75,7 +117,10 @@ test("running a query in a pack", async (t) => {
75
117
} ) ;
76
118
77
119
test ( "running multiple queries in a pack" , async ( t ) => {
78
- const queryPack = path . resolve ( "testdata/test_pack_multiple_queries" ) ;
120
+ const queryPack = await getQueryPackInfo (
121
+ "codeql" ,
122
+ "testdata/test_pack_multiple_queries" ,
123
+ ) ;
79
124
const tmpDir = fs . mkdtempSync ( "tmp" ) ;
80
125
const cwd = process . cwd ( ) ;
81
126
process . chdir ( tmpDir ) ;
@@ -175,10 +220,11 @@ test("getting the commit SHA when the codeql-database.yml does not exist", async
175
220
}
176
221
} ) ;
177
222
178
- test ( "getting the default query from a pack" , async ( t ) => {
179
- t . deepEqual ( await getQueryPackQueries ( "codeql" , "testdata/test_pack" ) , [
180
- path . resolve ( "testdata/test_pack/x/query.ql" ) ,
181
- ] ) ;
223
+ test ( "getting the queries from a pack" , async ( t ) => {
224
+ t . deepEqual (
225
+ await getQueryPackQueries ( "codeql" , "testdata/test_pack" , "codeql/queries" ) ,
226
+ [ path . resolve ( "testdata/test_pack/x/query.ql" ) ] ,
227
+ ) ;
182
228
} ) ;
183
229
184
230
test ( "populating the SARIF versionControlProvenance property" , ( t ) => {
0 commit comments