@@ -137,10 +137,31 @@ test("populateRunAutomationDetails", (t) => {
137
137
const analysisKey = ".github/workflows/codeql-analysis.yml:analyze" ;
138
138
139
139
let expectedSarif =
140
- '{"runs":[{"automationDetails":{"id":".github/workflows/codeql-analysis.yml:analyze/ language:javascript/os:linux/"}}]}' ;
140
+ '{"runs":[{"automationDetails":{"id":"language:javascript/os:linux/"}}]}' ;
141
141
142
+ // Category has priority over analysis_key/environment
142
143
let modifiedSarif = uploadLib . populateRunAutomationDetails (
143
144
sarif ,
145
+ "language:javascript/os:linux" ,
146
+ analysisKey ,
147
+ '{"language": "other", "os": "other"}'
148
+ ) ;
149
+ t . deepEqual ( modifiedSarif , expectedSarif ) ;
150
+
151
+ // It doesn't matter if the category has a slash at the end or not
152
+ modifiedSarif = uploadLib . populateRunAutomationDetails (
153
+ sarif ,
154
+ "language:javascript/os:linux/" ,
155
+ analysisKey ,
156
+ ""
157
+ ) ;
158
+ t . deepEqual ( modifiedSarif , expectedSarif ) ;
159
+
160
+ expectedSarif =
161
+ '{"runs":[{"automationDetails":{"id":".github/workflows/codeql-analysis.yml:analyze/language:javascript/os:linux/"}}]}' ;
162
+ modifiedSarif = uploadLib . populateRunAutomationDetails (
163
+ sarif ,
164
+ undefined ,
144
165
analysisKey ,
145
166
'{"language": "javascript", "os": "linux"}'
146
167
) ;
@@ -149,6 +170,7 @@ test("populateRunAutomationDetails", (t) => {
149
170
// check the environment sorting
150
171
modifiedSarif = uploadLib . populateRunAutomationDetails (
151
172
sarif ,
173
+ undefined ,
152
174
analysisKey ,
153
175
'{"os": "linux", "language": "javascript"}'
154
176
) ;
@@ -159,6 +181,7 @@ test("populateRunAutomationDetails", (t) => {
159
181
'{"runs":[{"automationDetails":{"id":".github/workflows/codeql-analysis.yml:analyze/"}}]}' ;
160
182
modifiedSarif = uploadLib . populateRunAutomationDetails (
161
183
sarif ,
184
+ undefined ,
162
185
analysisKey ,
163
186
"{}"
164
187
) ;
@@ -169,6 +192,7 @@ test("populateRunAutomationDetails", (t) => {
169
192
'{"runs":[{"automationDetails":{"id":".github/workflows/codeql-analysis.yml:analyze/number:/object:/"}}]}' ;
170
193
modifiedSarif = uploadLib . populateRunAutomationDetails (
171
194
sarif ,
195
+ undefined ,
172
196
analysisKey ,
173
197
'{"number": 1, "object": {"language": "javascript"}}'
174
198
) ;
@@ -179,6 +203,7 @@ test("populateRunAutomationDetails", (t) => {
179
203
expectedSarif = '{"runs":[{"automationDetails":{"id":"my_id"}}]}' ;
180
204
modifiedSarif = uploadLib . populateRunAutomationDetails (
181
205
sarif ,
206
+ undefined ,
182
207
analysisKey ,
183
208
'{"os": "linux", "language": "javascript"}'
184
209
) ;
0 commit comments