-
Notifications
You must be signed in to change notification settings - Fork 0
/
fail_level_test.go
73 lines (70 loc) · 1.83 KB
/
fail_level_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package reviewdog
import (
"testing"
"github.com/reviewdog/reviewdog/proto/rdf"
)
func TestShouldFail(t *testing.T) {
tests := []struct {
failLevel FailLevel
severity rdf.Severity
want bool
}{
{
failLevel: FailLevelDefault, severity: rdf.Severity_ERROR, want: false,
},
{
failLevel: FailLevelDefault, severity: rdf.Severity_WARNING, want: false,
},
{
failLevel: FailLevelDefault, severity: rdf.Severity_INFO, want: false,
},
{
failLevel: FailLevelDefault, severity: rdf.Severity_UNKNOWN_SEVERITY, want: false,
},
{
failLevel: FailLevelNone, severity: rdf.Severity_ERROR, want: false,
},
{
failLevel: FailLevelError, severity: rdf.Severity_ERROR, want: true,
},
{
failLevel: FailLevelError, severity: rdf.Severity_WARNING, want: false,
},
{
failLevel: FailLevelError, severity: rdf.Severity_INFO, want: false,
},
{
failLevel: FailLevelError, severity: rdf.Severity_UNKNOWN_SEVERITY, want: true,
},
{
failLevel: FailLevelWarning, severity: rdf.Severity_ERROR, want: true,
},
{
failLevel: FailLevelWarning, severity: rdf.Severity_WARNING, want: true,
},
{
failLevel: FailLevelWarning, severity: rdf.Severity_INFO, want: false,
},
{
failLevel: FailLevelWarning, severity: rdf.Severity_UNKNOWN_SEVERITY, want: true,
},
{
failLevel: FailLevelInfo, severity: rdf.Severity_ERROR, want: true,
},
{
failLevel: FailLevelInfo, severity: rdf.Severity_WARNING, want: true,
},
{
failLevel: FailLevelInfo, severity: rdf.Severity_INFO, want: true,
},
{
failLevel: FailLevelInfo, severity: rdf.Severity_UNKNOWN_SEVERITY, want: true,
},
}
for _, tt := range tests {
if got := tt.failLevel.ShouldFail(tt.severity); got != tt.want {
t.Errorf("FailLevel(%s).ShouldFail(%s) = %v, want %v", tt.failLevel.String(),
tt.severity, got, tt.want)
}
}
}