| 1 | package cmd |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | ) |
| 6 | |
| 7 | func TestSeveritiesAtOrAbove(t *testing.T) { |
| 8 | tests := []struct { |
| 9 | level string |
| 10 | included []string |
| 11 | excluded []string |
| 12 | }{ |
| 13 | { |
| 14 | level: "critical", |
| 15 | included: []string{"critical"}, |
| 16 | excluded: []string{"high", "medium", "low"}, |
| 17 | }, |
| 18 | { |
| 19 | level: "high", |
| 20 | included: []string{"high", "critical"}, |
| 21 | excluded: []string{"medium", "low"}, |
| 22 | }, |
| 23 | { |
| 24 | level: "medium", |
| 25 | included: []string{"medium", "high", "critical"}, |
| 26 | excluded: []string{"low"}, |
| 27 | }, |
| 28 | { |
| 29 | level: "low", |
| 30 | included: []string{"low", "medium", "high", "critical"}, |
| 31 | excluded: []string{}, |
| 32 | }, |
| 33 | { |
| 34 | level: "unknown", |
| 35 | included: []string{"critical"}, |
| 36 | excluded: []string{"high", "medium", "low"}, |
| 37 | }, |
| 38 | } |
| 39 | |
| 40 | for _, tt := range tests { |
| 41 | t.Run(tt.level, func(t *testing.T) { |
| 42 | result := severitiesAtOrAbove(tt.level) |
| 43 | for _, s := range tt.included { |
| 44 | if !result[s] { |
| 45 | t.Errorf("expected %q to be included for level %q", s, tt.level) |
| 46 | } |
| 47 | } |
| 48 | for _, s := range tt.excluded { |
| 49 | if result[s] { |
| 50 | t.Errorf("expected %q to be excluded for level %q", s, tt.level) |
| 51 | } |
| 52 | } |
| 53 | }) |
| 54 | } |
| 55 | } |