-
Notifications
You must be signed in to change notification settings - Fork 5
/
config_test.go
57 lines (52 loc) · 1.08 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
53
54
55
56
57
package dreck
import (
"testing"
yaml "gopkg.in/yaml.v2"
)
func TestOwnersConfigParse(t *testing.T) {
owners, err := parseOwners([]byte(`# Order is important; the last matching pattern takes the most
*.js @js-owner
* @miekg @blaa
`))
if err != nil {
t.Error(err)
}
if actual := len(owners); actual != 3 {
t.Errorf("want: %d approvers, got: %d", 3, actual)
}
found := false
for i := range owners {
if owners[i] == "miekg" {
found = true
}
}
if !found {
t.Errorf("want: %q in owners", "miekg")
}
}
func TestAliasConfigParse(t *testing.T) {
config := DreckConfig{}
buf := []byte(`aliases:
- |
/plugin (.*) - /label plugin/$1
`)
err := yaml.Unmarshal(buf, &config)
if err != nil {
t.Errorf("failed to parse config: %s", err)
}
actual := len(config.Aliases)
if actual != 1 {
t.Errorf("want: %d aliases, got: %d", 1, actual)
}
}
func TestConfigParse(t *testing.T) {
config := DreckConfig{}
buf := []byte(`aliases:
- >
/plugin (.*) - /label plugin/$1
`)
err := yaml.Unmarshal(buf, &config)
if err != nil {
t.Errorf("failed to parse config: %s", err)
}
}