Add automationdetails id to runs

This commit is contained in:
David Verdeguer 2021-04-15 16:20:49 +02:00
parent 6aebd1b98a
commit 47755f0910
6 changed files with 111 additions and 2 deletions

View file

@ -131,3 +131,36 @@ test("finding SARIF files", async (t) => {
]);
});
});
test("populateRunAutomationDetails", (t) => {
const sarif = '{"runs": [{}]}';
const analysisKey = ".github/workflows/codeql-analysis.yml:analyze";
let expectedSarif =
'{"runs":[{"automationDetails":{"id":".github/workflows/codeql-analysis.yml:analyze/language:javascript/os:linux/"}}]}';
let modifiedSarif = uploadLib.populateRunAutomationDetails(
sarif,
analysisKey,
'{"language": "javascript", "os": "linux"}'
);
t.deepEqual(modifiedSarif, expectedSarif);
// check the environment sorting
modifiedSarif = uploadLib.populateRunAutomationDetails(
sarif,
analysisKey,
'{"os": "linux", "language": "javascript"}'
);
t.deepEqual(modifiedSarif, expectedSarif);
// check that an empty environment produces the right results
expectedSarif =
'{"runs":[{"automationDetails":{"id":".github/workflows/codeql-analysis.yml:analyze/"}}]}';
modifiedSarif = uploadLib.populateRunAutomationDetails(
sarif,
analysisKey,
"{}"
);
t.deepEqual(modifiedSarif, expectedSarif);
});