@@ -2,18 +2,9 @@ import * as fs from "fs";
22
33import test from "ava" ;
44
5- import {
6- getRecordingLogger ,
7- LoggedMessage ,
8- setupTests ,
9- } from "../testing-utils" ;
5+ import { setupTests } from "../testing-utils" ;
106
11- import {
12- fixInvalidNotifications ,
13- getToolNames ,
14- SarifLocation ,
15- type SarifFile ,
16- } from "." ;
7+ import { getToolNames , type SarifFile } from "." ;
178
189setupTests ( test ) ;
1910
@@ -25,64 +16,3 @@ test("getToolNames", (t) => {
2516 const toolNames = getToolNames ( JSON . parse ( input ) as SarifFile ) ;
2617 t . deepEqual ( toolNames , [ "CodeQL command-line toolchain" , "ESLint" ] ) ;
2718} ) ;
28-
29- function createMockSarifWithNotification (
30- locations : SarifLocation [ ] ,
31- ) : SarifFile {
32- return {
33- runs : [
34- {
35- tool : {
36- driver : {
37- name : "CodeQL" ,
38- } ,
39- } ,
40- invocations : [
41- {
42- toolExecutionNotifications : [
43- {
44- locations,
45- } ,
46- ] ,
47- } ,
48- ] ,
49- } ,
50- ] ,
51- } ;
52- }
53-
54- const stubLocation : SarifLocation = {
55- physicalLocation : {
56- artifactLocation : {
57- uri : "file1" ,
58- } ,
59- } ,
60- } ;
61-
62- test ( "fixInvalidNotifications leaves notifications with unique locations alone" , ( t ) => {
63- const messages : LoggedMessage [ ] = [ ] ;
64- const result = fixInvalidNotifications (
65- createMockSarifWithNotification ( [ stubLocation ] ) ,
66- getRecordingLogger ( messages ) ,
67- ) ;
68- t . deepEqual ( result , createMockSarifWithNotification ( [ stubLocation ] ) ) ;
69- t . is ( messages . length , 1 ) ;
70- t . deepEqual ( messages [ 0 ] , {
71- type : "debug" ,
72- message : "No duplicate locations found in SARIF notification objects." ,
73- } ) ;
74- } ) ;
75-
76- test ( "fixInvalidNotifications removes duplicate locations" , ( t ) => {
77- const messages : LoggedMessage [ ] = [ ] ;
78- const result = fixInvalidNotifications (
79- createMockSarifWithNotification ( [ stubLocation , stubLocation ] ) ,
80- getRecordingLogger ( messages ) ,
81- ) ;
82- t . deepEqual ( result , createMockSarifWithNotification ( [ stubLocation ] ) ) ;
83- t . is ( messages . length , 1 ) ;
84- t . deepEqual ( messages [ 0 ] , {
85- type : "info" ,
86- message : "Removed 1 duplicate locations from SARIF notification objects." ,
87- } ) ;
88- } ) ;
0 commit comments