-
Notifications
You must be signed in to change notification settings - Fork 0
/
yaml_test.go
63 lines (54 loc) · 1.15 KB
/
yaml_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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
var fullYaml = `
strategies:
run:
handler: docker_compose_run
service: app
remove: true
run_with_docker:
handler: docker_run
image: alpine:latest
port: "8080:80"
volumes:
- "./:/usr/src/app"
default_strategy: run
commands:
ls: run_with_docker
bundle: run
`
var yamlWithExtraAttributes = fullYaml + `
something-else:
foo: bar
`
func TestParseYaml(t *testing.T) {
expectedResult := &yamlCfg{
Strategies: map[string]map[string]interface{}{
"run": {
"handler": "docker_compose_run",
"service": "app",
"remove": true,
},
"run_with_docker": {
"handler": "docker_run",
"image": "alpine:latest",
"port": "8080:80",
"volumes": []interface{}{"./:/usr/src/app"},
},
},
DefaultStrategy: "run",
Commands: map[string]string{
"ls": "run_with_docker",
"bundle": "run",
},
}
yaml, err := parseYaml([]byte(fullYaml))
assert.NoError(t, err)
assert.Equal(t, yaml, expectedResult)
yaml, err = parseYaml([]byte(yamlWithExtraAttributes))
assert.NoError(t, err)
assert.Equal(t, yaml, expectedResult)
}