-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
59 lines (53 loc) · 1.21 KB
/
main_test.go
File metadata and controls
59 lines (53 loc) · 1.21 KB
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
package main
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestConfig_Attributes(t *testing.T) {
config := testConfig(t)
assert.Equal(t, map[string]bool{"image": true}, config.attributes("container", "start"))
assert.Equal(t, map[string]bool{"image": false}, config.attributes("container", "create"))
assert.Equal(t, map[string]bool{"image": true, "exitCode": true}, config.attributes("container", "die"))
assert.Equal(t, map[string]bool{"image": true, "signal": true}, config.attributes("container", "kill"))
}
const testConfigJson = `{
"attributes": {
"image": true
},
"events": {
"image": {
"actions": {
"pull": {},
"delete": {}
}
},
"container": {
"actions": {
"create": {
"attributes": {
"image": false
}
},
"start": {},
"die": {
"attributes": {
"exitCode": true
}
},
"kill": {
"attributes": {
"signal": true
}
}
}
}
}
}`
func testConfig(t testing.TB) *config {
config, err := loadConfig(strings.NewReader(testConfigJson))
if err != nil {
t.Fatal(err)
}
return config
}