-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparse_test.go
67 lines (56 loc) · 1.49 KB
/
parse_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
64
65
66
67
package bitbucket
import "testing"
func TestParse(t *testing.T) {
config, err := ParseString(sample)
if err != nil {
t.Error(err)
return
}
if want, got := config.Clone.Depth, 25; want != got {
t.Errorf("Wanted clone depth %d, got %d", want, got)
}
if want, got := len(config.Pipelines.Default.Steps), 2; want != got {
t.Errorf("Wanted default.step length %d, got %d", want, got)
t.FailNow()
}
if want, got := config.Pipelines.Default.Steps[0].Image, "golang:1.7"; want != got {
t.Errorf("Wanted default.step.0.image %s, got %s", want, got)
}
if want, got := len(config.Pipelines.Default.Steps[0].Script), 2; want != got {
t.Errorf("Wanted default.step.0.step length %d, got %d", want, got)
}
if want, got := config.Pipelines.Default.Steps[0].Script[0], "go build"; want != got {
t.Errorf("Wanted default.step.0.step.0 equal to %s, got %s", want, got)
}
if want, got := config.Pipelines.Default.Steps[1].Image, ""; want != got {
t.Errorf("Wanted default.step.0.image equal to %q, got %s", want, got)
}
}
var sample = `
image: node:latest
clone:
depth: 25
pipelines:
default:
- step:
image: golang:1.7
script:
- go build
- go test
- step:
script:
- npm install
- npm test
tags:
release-*:
- step:
script:
- npm install
- npm test
- npm run release
branches:
staging:
- step:
script:
- echo "Clone all the things!"
`