-
Notifications
You must be signed in to change notification settings - Fork 6
/
builder_test.go
50 lines (43 loc) · 926 Bytes
/
builder_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
package main
import (
"os"
"testing"
)
func cleanBuildTargetDir(path string) {
os.RemoveAll(path)
}
func TestCreateBuildTargetDir(t *testing.T) {
targetDir := "test_tmp_dir"
err := createBuildTargetDir(targetDir)
if err != nil {
t.Fatal(err)
}
defer cleanBuildTargetDir(targetDir)
s, err := os.Stat(targetDir)
if err != nil {
t.Fatal(err)
}
if s.Name() != targetDir {
t.Errorf("expected %s but got %s", targetDir, s.Name())
}
}
func TestBuilderBuild(t *testing.T) {
targetDir := "test_tmp_dir"
err := createBuildTargetDir(targetDir)
if err != nil {
t.Fatal(err)
}
defer cleanBuildTargetDir(targetDir)
os.Setenv("WBS_TEST_SERVER_ROOT", "test_tmp_dir")
config, err := NewConfig("./wbs.example.toml")
if err != nil {
t.Fatal(err)
}
builder, err := NewBuilder(config)
if err != nil {
t.Fatal(err)
}
if err := builder.Build(); err != nil {
t.Errorf("failed to execute: %s", err)
}
}