-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig_test.go
53 lines (49 loc) · 928 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
package main
import (
"path"
"strings"
"testing"
)
func TestInvalidConfig(t *testing.T) {
testCases := []struct {
path string
message string
}{
{
path: "missing-title.toml",
message: "index.title",
},
{
path: "missing-domain.toml",
message: "domain",
},
{
path: "missing-repo.toml",
message: "repo",
},
{
path: "missing-vcs.toml",
message: "vcs",
},
}
for _, tC := range testCases {
t.Run(tC.path, func(t *testing.T) {
_, err := newConfig(path.Join("fixtures", tC.path))
if err != nil && !strings.Contains(err.Error(), tC.message) {
t.Errorf("'%s' does not contains '%s'", err, tC.message)
}
})
}
}
func TestSampleConfigIsValid(t *testing.T) {
err := initSampleConfig()
if err != nil {
t.Error(err)
}
}
func TestValidConfig(t *testing.T) {
_, err := newConfig(path.Join("fixtures", "valid.toml"))
if err != nil {
t.Error(err)
}
}