forked from skynetservices/skynet-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcriteria_test.go
50 lines (45 loc) · 882 Bytes
/
criteria_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
package skynet
import (
"testing"
)
type matchTestCase struct {
Criteria Criteria
MatchingInstances []ServiceInfo
NonMatchingInstances []ServiceInfo
}
var testCases []matchTestCase = []matchTestCase{
matchTestCase{
Criteria: Criteria{
Regions: []string{
"Tampa",
},
},
MatchingInstances: []ServiceInfo{
ServiceInfo{
Region: "Tampa",
},
},
NonMatchingInstances: []ServiceInfo{
ServiceInfo{
Region: "Chicago",
},
ServiceInfo{
Region: "Dallas",
},
},
},
}
func TestMatch(t *testing.T) {
for _, tc := range testCases {
for _, i := range tc.MatchingInstances {
if !tc.Criteria.Matches(i) {
t.Fatal("Instance expected to match criteria and did not")
}
}
for _, i := range tc.NonMatchingInstances {
if tc.Criteria.Matches(i) {
t.Fatal("Instance should not match criteria")
}
}
}
}