-
Notifications
You must be signed in to change notification settings - Fork 250
/
builder_go_module_test.go
82 lines (62 loc) · 2.2 KB
/
builder_go_module_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
package builder_test
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"testing"
"github.com/cucumber/godog"
)
func testOutsideGopathAndHavingOnlyFeature(t *testing.T) {
builderTC := builderTestCase{}
builderTC.dir = filepath.Join(os.TempDir(), t.Name(), "godogs")
builderTC.files = map[string]string{
"godogs.feature": builderFeatureFile,
}
builderTC.goModCmds = make([]*exec.Cmd, 2)
builderTC.goModCmds[0] = exec.Command("go", "mod", "init", "godogs")
godogDependency := fmt.Sprintf("github.com/cucumber/godog@%s", godog.Version)
builderTC.goModCmds[1] = exec.Command("go", "mod", "edit", "-require", godogDependency)
builderTC.run(t)
}
func testOutsideGopath(t *testing.T) {
builderTC := builderTestCase{}
builderTC.dir = filepath.Join(os.TempDir(), t.Name(), "godogs")
builderTC.files = map[string]string{
"godogs.feature": builderFeatureFile,
"godogs.go": builderMainCodeFile,
"godogs_test.go": builderTestFile,
}
builderTC.goModCmds = make([]*exec.Cmd, 1)
builderTC.goModCmds[0] = exec.Command("go", "mod", "init", "godogs")
builderTC.run(t)
}
func testOutsideGopathWithXTest(t *testing.T) {
builderTC := builderTestCase{}
builderTC.dir = filepath.Join(os.TempDir(), t.Name(), "godogs")
builderTC.files = map[string]string{
"godogs.feature": builderFeatureFile,
"godogs.go": builderMainCodeFile,
"godogs_test.go": builderXTestFile,
}
builderTC.goModCmds = make([]*exec.Cmd, 1)
builderTC.goModCmds[0] = exec.Command("go", "mod", "init", "godogs")
builderTC.run(t)
}
func testInsideGopath(t *testing.T) {
builderTC := builderTestCase{}
gopath := filepath.Join(os.TempDir(), t.Name(), "_gp")
defer os.RemoveAll(gopath)
builderTC.dir = filepath.Join(gopath, "src", "godogs")
builderTC.files = map[string]string{
"godogs.feature": builderFeatureFile,
"godogs.go": builderMainCodeFile,
"godogs_test.go": builderTestFile,
}
builderTC.goModCmds = make([]*exec.Cmd, 1)
builderTC.goModCmds[0] = exec.Command("go", "mod", "init", "godogs")
builderTC.goModCmds[0].Env = os.Environ()
builderTC.goModCmds[0].Env = append(builderTC.goModCmds[0].Env, "GOPATH="+gopath)
builderTC.goModCmds[0].Env = append(builderTC.goModCmds[0].Env, "GO111MODULE=on")
builderTC.run(t)
}