-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
presenter_test.go
69 lines (64 loc) · 1.13 KB
/
presenter_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
package main
import "testing"
func TestWillUpdateRulesAndTargets(t *testing.T) {
rules := []Rule{
{
Name: "Rule1",
NeedUpdate: true,
},
{
Name: "Rule2",
NeedUpdate: false,
Targets: []Target{
{
ID: "Target1",
NeedUpdate: true,
},
},
},
{
Name: "Rule3",
NeedUpdate: false,
},
}
result := WillUpdateRulesAndTargets(rules)
if len(result) != 2 {
t.Errorf("result should be including 2 rules")
}
for _, rule := range result {
if rule.Name == "Rule3" {
t.Errorf("result shouldn't including Rule3")
}
}
}
func TestWillDeleteRulesAndTargets(t *testing.T) {
rules := []Rule{
{
Name: "Rule1",
NeedDelete: true,
},
{
Name: "Rule2",
NeedDelete: false,
Targets: []Target{
{
ID: "Target1",
NeedDelete: true,
},
},
},
{
Name: "Rule3",
NeedUpdate: false,
},
}
result := WillDeleteRulesAndTargets(rules)
if len(result) != 2 {
t.Errorf("result should be including 2 rules")
}
for _, rule := range result {
if rule.Name == "Rule3" {
t.Errorf("result shouldn't including Rule3")
}
}
}