summaryrefslogtreecommitdiff
path: root/cmd/ponzu/new_test.go
diff options
context:
space:
mode:
authorMartin Treusch von Buttlar <martin.tvb@vitraum.de>2017-05-20 13:11:27 +0200
committerMartin Treusch von Buttlar <martin.tvb@vitraum.de>2017-05-20 13:11:27 +0200
commit6de9e9030108af25bf3c9cace0acc987f39ef2fd (patch)
tree0644a4d38e40bb50a230a2fddd8d8e08aa9557ba /cmd/ponzu/new_test.go
parent372ce32e444c34c9107b5da22c847eb368466cc9 (diff)
add more tests for 'ponzu new' - run with 'go test . -run Check -v'
Diffstat (limited to 'cmd/ponzu/new_test.go')
-rw-r--r--cmd/ponzu/new_test.go41
1 files changed, 28 insertions, 13 deletions
diff --git a/cmd/ponzu/new_test.go b/cmd/ponzu/new_test.go
index a143d1a..cda55a6 100644
--- a/cmd/ponzu/new_test.go
+++ b/cmd/ponzu/new_test.go
@@ -15,28 +15,43 @@ func TestNewCheckNmkAbs(t *testing.T) {
}
isNil := func(e error) bool { return e == nil }
+ isNonNil := func(e error) bool { return e != nil }
+
+ baseDir := filepath.Join(pwd, "test-fixtures", "new")
testTable := []struct {
- base, wd, a,
+ gopath, wd, a,
wantP string
wantE func(e error) bool
}{{
- base: filepath.Join(pwd, "test-fixtures", "new"),
- wd: filepath.Join("src", "existing"),
- a: ".",
- wantP: filepath.Join(pwd, "test-fixtures", "new", "src", "existing"),
- wantE: os.IsExist,
+ gopath: baseDir,
+ wd: filepath.Join("src", "existing"),
+ a: ".",
+ wantP: filepath.Join(pwd, "test-fixtures", "new", "src", "existing"),
+ wantE: os.IsExist,
+ }, {
+ gopath: baseDir,
+ wd: filepath.Join(""),
+ a: "non-existing",
+ wantP: filepath.Join(pwd, "test-fixtures", "new", "src", "non-existing"),
+ wantE: isNil,
+ }, {
+ gopath: baseDir,
+ wd: filepath.Join(""),
+ a: ".",
+ wantP: "",
+ wantE: isNonNil,
}, {
- base: filepath.Join(pwd, "test-fixtures", "new"),
- wd: filepath.Join(""),
- a: "non-existing",
- wantP: filepath.Join(pwd, "test-fixtures", "new", "src", "non-existing"),
- wantE: isNil,
+ gopath: baseDir,
+ wd: "..",
+ a: ".",
+ wantP: "",
+ wantE: isNonNil,
}}
for _, test := range testTable {
- os.Setenv("GOPATH", test.base)
- err = os.Chdir(filepath.Join(test.base, test.wd))
+ os.Setenv("GOPATH", test.gopath)
+ err = os.Chdir(filepath.Join(test.gopath, test.wd))
if err != nil {
t.Fatalf("could not setup base: %s", err)
}