-
Notifications
You must be signed in to change notification settings - Fork 9
/
build_test.go
98 lines (78 loc) · 1.88 KB
/
build_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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package test161
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestBuildFull(t *testing.T) {
t.Parallel()
assert := assert.New(t)
conf := &BuildConf{
Repo: "https://github.com/ops-class/os161.git",
CommitID: "HEAD",
KConfig: "DUMBVM",
}
env := defaultEnv.CopyEnvironment()
env.RootDir = "./fixtures/root"
test, err := conf.ToBuildTest(env)
assert.Nil(err)
assert.NotNil(test)
if test == nil {
t.Log(err)
t.FailNow()
}
_, err = test.Run(env)
assert.Nil(err)
t.Log(test.OutputJSON())
for k, v := range env.keyMap {
t.Log(k, v)
}
}
type confDetail struct {
repo string
commit string
config string
reqCommit string
}
func TestBuildFailures(t *testing.T) {
t.Parallel()
assert := assert.New(t)
configs := []confDetail{
confDetail{"https://notgithub.com/ops-class/os161111.git", "HEAD", "DUMBVM", ""},
confDetail{"https://github.com/ops-class/os161.git", "aaaaaaaaaaa111111112222", "FOO", ""},
confDetail{"https://github.com/ops-class/os161.git", "HEAD", "FOO", ""},
confDetail{"https://github.com/ops-class/os161.git", "HEAD", "DUMBVM", "notavalidcommitit"},
}
for _, c := range configs {
conf := &BuildConf{
Repo: c.repo,
CommitID: c.commit,
KConfig: c.config,
RequiredCommit: c.reqCommit,
}
test, err := conf.ToBuildTest(defaultEnv)
assert.NotNil(test)
res, err := test.Run(defaultEnv)
assert.NotNil(err)
assert.Nil(res)
}
}
func TestHexString(t *testing.T) {
t.Parallel()
assert := assert.New(t)
testCases := []struct {
input string
expected bool
}{
{"0123456789abcdef", true},
{"0123456789ABCDEF", true},
{"e1a2fbd038c618b6d9e636a94e1907dc92e94ca6", true},
{"", false},
{"foo", false},
{"0123456789abcdefg", false},
{"!", false},
}
for _, test := range testCases {
t.Log(test.input)
assert.Equal(test.expected, isHexString(test.input))
}
}