/
build_test.go
75 lines (58 loc) · 1.43 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
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)
}
}