-
Notifications
You must be signed in to change notification settings - Fork 1
/
config_test.go
52 lines (45 loc) · 1.1 KB
/
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
package bitbucket
import (
"reflect"
"testing"
)
func TestMatchPipeline(t *testing.T) {
config, err := ParseString(pipelineYaml)
if err != nil {
t.Error(err)
return
}
got, want := config.Pipeline("refs/tags/release-1.0", "master"), config.Pipelines.Tags["release-*"]
if !reflect.DeepEqual(got, want) {
t.Errorf("Expect release-* pipeline matches release-1.0")
}
got, want = config.Pipeline("", "staging"), config.Pipelines.Branches["staging"]
if !reflect.DeepEqual(got, want) {
t.Errorf("Expect staging pipeline matches staging branch")
}
got, want = config.Pipeline("refs/tags/v1.0.0", "master"), config.Pipelines.Default
if !reflect.DeepEqual(got, want) {
t.Errorf("Expect default branch used when no match is found")
}
}
var pipelineYaml = `
image: node:latest
pipelines:
default:
- 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!"
`