-
Notifications
You must be signed in to change notification settings - Fork 1
/
testfile_test.go
58 lines (51 loc) · 1.01 KB
/
testfile_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
package testbot
import (
"reflect"
"strings"
"testing"
)
const sampleTestfile = `
# this is a comment
gotest: go test ./...
gocompile: go install chain/... # this is an end-of-line comment
`
func TestParseCommands(t *testing.T) {
want := map[string]string{
"gotest": "go test ./...",
"gocompile": "go install chain/... # this is an end-of-line comment",
}
got, err := ParseTestfile(strings.NewReader(sampleTestfile))
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(got, want) {
t.Errorf("ParseTestfile(%#q) = %v, want %v", sampleTestfile, got, want)
}
}
func TestOkNameOk(t *testing.T) {
cases := []string{
"web",
"a",
"a123",
"123",
"name_with_underscore",
}
for _, test := range cases {
if !okName([]byte(test)) {
t.Errorf("okName(%q) = false, want true", test)
}
}
}
func TestOkNameBad(t *testing.T) {
cases := []string{
"",
" ",
"a.b",
"a-",
}
for _, test := range cases {
if okName([]byte(test)) {
t.Errorf("okName(%q) = true, want false", test)
}
}
}