-
Notifications
You must be signed in to change notification settings - Fork 7
/
utils_test.go
60 lines (55 loc) · 1.24 KB
/
utils_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
package kommons
import "testing"
type healthFixture struct {
Name string
H1, H2 Health
Result bool
}
func TestHealthComparisons(t *testing.T) {
fixtures := []healthFixture{
{
Name: "all healthy",
H1: Health{RunningPods: 10},
H2: Health{RunningPods: 10},
Result: false,
},
{
Name: "less healthy",
H1: Health{RunningPods: 8},
H2: Health{RunningPods: 10},
Result: true,
},
{
Name: "more healthy",
H1: Health{RunningPods: 12},
H2: Health{RunningPods: 10},
Result: false,
},
{
Name: "some unhealthy pods",
H1: Health{RunningPods: 10, CrashLoopBackOff: 2},
H2: Health{RunningPods: 10},
Result: true,
},
{
Name: "more unhealthy pods",
H1: Health{RunningPods: 10, CrashLoopBackOff: 4},
H2: Health{RunningPods: 10, CrashLoopBackOff: 2},
Result: true,
},
{
Name: "same unhealthy pods",
H1: Health{RunningPods: 10, CrashLoopBackOff: 2},
H2: Health{RunningPods: 10, CrashLoopBackOff: 2},
Result: false,
},
}
for _, fixture := range fixtures {
_fixture := fixture
t.Run(fixture.Name, func(t *testing.T) {
if _fixture.H1.IsDegradedComparedTo(_fixture.H2, 1) != _fixture.Result {
t.Fail()
}
})
}
}