-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig_test.go
More file actions
36 lines (32 loc) · 797 Bytes
/
config_test.go
File metadata and controls
36 lines (32 loc) · 797 Bytes
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
package main_test
import (
"bytes"
"testing"
"github.com/dhamidi/leader"
"github.com/stretchr/testify/assert"
)
var exampleConfig = `
{
"keys": {
"d": "date",
"r": {
"name": "rake",
"loopingKeys": ["t"],
"keys": {
"t": "bundle exec rake test"
}
}
}
}
`
func TestConfig_ParseJSON(t *testing.T) {
config := main.NewConfig()
assert.NoError(t, config.ParseJSON(bytes.NewBufferString(exampleConfig)))
assert.Equal(t, "root", *config.Root.Name)
assert.Equal(t, "date", *(config.Root.Keys["d"].ShellCommand))
assert.Equal(t, "bundle exec rake test",
*(config.Root.Keys["r"].Child.Keys["t"].ShellCommand),
)
assert.Contains(t, (*config.Root.Keys["r"].Child).LoopingKeys, "t")
assert.Equal(t, "rake", *(config.Root.Keys["r"].Child.Name))
}