forked from coreos/mayday
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mayday_test.go
50 lines (42 loc) · 1001 Bytes
/
mayday_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 main
import (
"strings"
"testing"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
)
const (
confStr = `{
"files": [
{
"name": "/proc/vmstat"
}, {
"name": "/proc/meminfo",
"link": "meminfo"
}
],
"commands": [
{
"args": ["hostname"]
},
{
"args": ["lsof", "-b", "-M", "-n", "-l"],
"link": "lsof"
}
]
}
`
)
func TestConfigStruct(t *testing.T) {
// test that the config struct is set up to unmarshal a config file
viper.SetConfigType("yaml")
viper.ReadConfig(strings.NewReader(confStr))
var C Config
viper.Unmarshal(&C)
command0 := Command{Args: []string{"hostname"}}
assert.EqualValues(t, C.Commands[0], command0)
command1 := Command{Args: []string{"lsof", "-b", "-M", "-n", "-l"}, Link: "lsof"}
assert.EqualValues(t, C.Commands[1], command1)
assert.EqualValues(t, C.Files[0], File{Name: "/proc/vmstat"})
assert.EqualValues(t, C.Files[1], File{Name: "/proc/meminfo", Link: "meminfo"})
}