mirror of
https://github.com/github/codeql-action.git
synced 2025-12-21 14:50:08 +08:00
Implement removing duplicate locations from a SARIF file
This commit is contained in:
45
lib/util.test.js
generated
45
lib/util.test.js
generated
@@ -330,4 +330,49 @@ const shortTime = 10;
|
||||
t.deepEqual(shortTaskTimedOut, false);
|
||||
t.deepEqual(result, 99);
|
||||
});
|
||||
function createMockSarifWithNotification(locations) {
|
||||
return {
|
||||
runs: [
|
||||
{
|
||||
tool: {
|
||||
driver: {
|
||||
name: "CodeQL",
|
||||
},
|
||||
},
|
||||
invocations: [
|
||||
{
|
||||
toolExecutionNotifications: [
|
||||
{
|
||||
locations,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
const stubLocation = {
|
||||
physicalLocation: {
|
||||
artifactLocation: {
|
||||
uri: "file1",
|
||||
},
|
||||
},
|
||||
};
|
||||
(0, ava_1.default)("fixInvalidNotifications leaves notifications with unique locations alone", (t) => {
|
||||
const messages = [];
|
||||
const result = util.fixInvalidNotifications(createMockSarifWithNotification([stubLocation]), (0, testing_utils_1.getRecordingLogger)(messages));
|
||||
t.deepEqual(result, createMockSarifWithNotification([stubLocation]));
|
||||
t.is(messages.length, 0);
|
||||
});
|
||||
(0, ava_1.default)("fixInvalidNotifications removes duplicate locations", (t) => {
|
||||
const messages = [];
|
||||
const result = util.fixInvalidNotifications(createMockSarifWithNotification([stubLocation, stubLocation]), (0, testing_utils_1.getRecordingLogger)(messages));
|
||||
t.deepEqual(result, createMockSarifWithNotification([stubLocation]));
|
||||
t.is(messages.length, 1);
|
||||
t.deepEqual(messages[0], {
|
||||
type: "info",
|
||||
message: "Removed 1 duplicate locations from SARIF notification objects.",
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=util.test.js.map
|
||||
Reference in New Issue
Block a user