-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconfig_test.go
58 lines (50 loc) · 935 Bytes
/
config_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
package main
import "testing"
func TestParseCommand(t *testing.T) {
configs := [][]string{
{`
stage:
image: img
shell: sh
commands:
- run1
- run2
- run3
env:
foo: bar
cached:
- dir1
`, `
#0 :: 0:stage:Command:img:sh:cmds[run1,run2,run3]:env[foo=bar]:cached[dir1]
`,
},
{`
stage1:
image: img1
commands:
- run1
stage2:
image: img2
commands:
- run2
`, `
#0 :: 0:stage1:Command:img1::cmds[run1]
#1 :: 1:stage2:Command:img2::cmds[run2]
`,
},
}
for _, c := range configs {
p, err := Parse([]byte(c[0]))
if err != nil {
t.Errorf("Failed to parse yml content %s", err)
return
}
pipeline := Pipeline{p, "test"}
expected := c[1]
actual := pipeline.String()
if actual != expected {
t.Errorf("Parsed config does not match expected: \n\nexpected:\n%s \n\nactual:\n%s", expected, actual)
return
}
}
}