github.com/devseccon/trivy@v0.47.1-0.20231123133102-bd902a0bd996/pkg/report/writer_internal_test.go (about) 1 package report 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestReportWriter_toSarifErrorLevel(t *testing.T) { 10 tests := []struct { 11 severity string 12 sarifErrorLevel string 13 }{ 14 { 15 severity: "CRITICAL", 16 sarifErrorLevel: "error", 17 }, 18 { 19 severity: "HIGH", 20 sarifErrorLevel: "error", 21 }, 22 { 23 severity: "MEDIUM", 24 sarifErrorLevel: "warning", 25 }, 26 { 27 severity: "LOW", 28 sarifErrorLevel: "note", 29 }, 30 { 31 severity: "UNKNOWN", 32 sarifErrorLevel: "note", 33 }, 34 { 35 severity: "OTHER", 36 sarifErrorLevel: "none", 37 }, 38 } 39 for _, tc := range tests { 40 t.Run(tc.severity, func(t *testing.T) { 41 assert.Equal(t, tc.sarifErrorLevel, toSarifErrorLevel(tc.severity), tc.severity) 42 }) 43 } 44 }