-
Notifications
You must be signed in to change notification settings - Fork 3
/
realworld_test.go
71 lines (64 loc) · 1.65 KB
/
realworld_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
package connor_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/SierraSoftworks/connor"
)
var _ = Describe("Real World Cases", func() {
Describe("Sensu Check", func() {
conds := map[string]interface{}{
"check.status": 0,
}
data := map[string]interface{}{
"client": "razz-base-stackstorm",
"check": map[string]interface{}{
"command": "/opt/sensu/embedded/bin/check-cpu.rb",
"handlers": []interface{}{"default", "st2"},
"name": "CPU",
"issued": 1487492532,
"interval": 60,
"subscribers": []interface{}{"generic"},
"executed": 1487492532,
"duration": 1.115,
"output": "This is a quick test",
"status": 0,
"remediations": []interface{}{
map[string]interface{}{
"name": "all good",
"command": "echo 'OK' > check_handler.dat",
"conditions": map[string]interface{}{
"check.status": 0,
},
},
map[string]interface{}{
"name": "so-so",
"command": "echo 'WARN' > check_handler.dat",
"conditions": map[string]interface{}{
"check.status": 1,
"occurrences": 2,
},
},
map[string]interface{}{
"name": "it's on fire!",
"command": "echo 'CRIT' > check_handler.dat",
"conditions": map[string]interface{}{
"check.status": 2,
"occurrences": 2,
},
},
},
},
}
var matches bool
var err error
BeforeEach(func() {
matches, err = Match(conds, data)
})
It("should not return an error", func() {
Expect(err).To(Succeed())
})
It("should match", func() {
Expect(matches).To(BeTrue())
})
})
})