-
Notifications
You must be signed in to change notification settings - Fork 3
/
urgency_test.go
82 lines (73 loc) · 2.23 KB
/
urgency_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
74
75
76
77
78
79
80
81
82
package libhealth
import (
"testing"
"github.com/stretchr/testify/require"
)
func Test_ParseUrgency(t *testing.T) {
testcases := []struct {
urgencies []string
exp Urgency
}{
{
urgencies: []string{"REQUIRED", "Required", "required"},
exp: REQUIRED,
},
{
urgencies: []string{"STRONG", "Strong", "strong"},
exp: STRONG,
},
{
urgencies: []string{"WEAK", "Weak", "weak"},
exp: WEAK,
},
{
urgencies: []string{"NONE", "None", "none"},
exp: NONE,
},
{
urgencies: []string{"UNKNOWN", "Unknown", "unknown", "", "\t", "abc123"},
exp: UNKNOWN,
},
}
for _, test := range testcases {
for _, urgency := range test.urgencies {
parsed := ParseUrgency(urgency)
require.Equal(t, test.exp, parsed)
}
}
}
func Test_DowngradeWith_required(t *testing.T) {
subject := REQUIRED
require.Equal(t, OK, subject.DowngradeWith(OK, OK))
require.Equal(t, MINOR, subject.DowngradeWith(OK, MINOR))
require.Equal(t, MAJOR, subject.DowngradeWith(OK, MAJOR))
require.Equal(t, OUTAGE, subject.DowngradeWith(OK, OUTAGE))
}
func Test_DowngradeWith_strong(t *testing.T) {
subject := STRONG
require.Equal(t, OK, subject.DowngradeWith(OK, OK))
require.Equal(t, MINOR, subject.DowngradeWith(OK, MINOR))
require.Equal(t, MAJOR, subject.DowngradeWith(OK, MAJOR))
require.Equal(t, MAJOR, subject.DowngradeWith(OK, OUTAGE))
}
func Test_DowngradeWith_weak(t *testing.T) {
subject := WEAK
require.Equal(t, OK, subject.DowngradeWith(OK, OK))
require.Equal(t, MINOR, subject.DowngradeWith(OK, MINOR))
require.Equal(t, MINOR, subject.DowngradeWith(OK, MAJOR))
require.Equal(t, MINOR, subject.DowngradeWith(OK, OUTAGE))
}
func Test_DowngradeWith_none(t *testing.T) {
subject := NONE
require.Equal(t, OK, subject.DowngradeWith(OK, OK))
require.Equal(t, OK, subject.DowngradeWith(OK, MINOR))
require.Equal(t, OK, subject.DowngradeWith(OK, MAJOR))
require.Equal(t, OK, subject.DowngradeWith(OK, OUTAGE))
}
func Test_DowngradeWith_unknown(t *testing.T) {
subject := UNKNOWN
require.Equal(t, OK, subject.DowngradeWith(OK, OK))
require.Equal(t, MINOR, subject.DowngradeWith(OK, MINOR))
require.Equal(t, MAJOR, subject.DowngradeWith(OK, MAJOR))
require.Equal(t, OUTAGE, subject.DowngradeWith(OK, OUTAGE))
}