@@ -227,3 +227,40 @@ func TestBuildToolParams_SARIFCompareAlertsWithConfig(t *testing.T) {
227227 t .Error ("expected sarifPath injected into alertB" )
228228 }
229229}
230+
231+ func TestBuildToolParams_SARIFDiffByCommitsWithConfig (t * testing.T ) {
232+ dir := t .TempDir ()
233+ testDir := filepath .Join (dir , "tools" , "sarif_diff_by_commits" , "file_level_classification" )
234+ beforeDir := filepath .Join (testDir , "before" )
235+ os .MkdirAll (beforeDir , 0o755 )
236+ os .MkdirAll (filepath .Join (testDir , "after" ), 0o755 )
237+
238+ // Write test-config.json with refRange and granularity but no sarifPath
239+ os .WriteFile (filepath .Join (testDir , "test-config.json" ),
240+ []byte (`{"toolName":"sarif_diff_by_commits","arguments":{"refRange":"HEAD..HEAD","granularity":"file"}}` ), 0o600 )
241+
242+ // Write a SARIF file in before/
243+ os .WriteFile (filepath .Join (beforeDir , "results.sarif" ),
244+ []byte (`{"version":"2.1.0","runs":[{"tool":{"driver":{"name":"CodeQL","rules":[]}},"results":[]}]}` ), 0o600 )
245+
246+ params , err := buildToolParams (dir , "sarif_diff_by_commits" , "file_level_classification" , testDir )
247+ if err != nil {
248+ t .Fatalf ("unexpected error: %v" , err )
249+ }
250+
251+ // Should have sarifPath injected from before/
252+ sarifPath , ok := params ["sarifPath" ].(string )
253+ if ! ok || sarifPath == "" {
254+ t .Error ("expected sarifPath to be injected from before/ directory" )
255+ }
256+
257+ // Should have refRange from config
258+ if params ["refRange" ] != "HEAD..HEAD" {
259+ t .Errorf ("params[refRange] = %v, want HEAD..HEAD" , params ["refRange" ])
260+ }
261+
262+ // Should have granularity from config
263+ if params ["granularity" ] != "file" {
264+ t .Errorf ("params[granularity] = %v, want file" , params ["granularity" ])
265+ }
266+ }
0 commit comments