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
|
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParse(t *testing.T) {
path, clean := TempFile(t, `
url: google.golang.org
packages:
grpc:
repo: github.com/grpc/grpc-go
`)
defer clean()
config, err := Parse(path)
assert.NoError(t, err)
assert.Equal(t, config.URL, "google.golang.org")
pkg, ok := config.Packages["grpc"]
assert.True(t, ok)
assert.Equal(t, pkg, Package{Repo: "github.com/grpc/grpc-go"})
}
func TestNotAlphabetical(t *testing.T) {
path, clean := TempFile(t, `
url: google.golang.org
packages:
grpc:
repo: github.com/grpc/grpc-go
atomic:
repo: github.com/uber-go/atomic
`)
defer clean()
_, err := Parse(path)
if assert.Error(t, err, "YAML configuration is not listed alphabetically") {
assert.Contains(t, err.Error(), "must be alphabetically ordered")
}
}
|