From 6de9e9030108af25bf3c9cace0acc987f39ef2fd Mon Sep 17 00:00:00 2001 From: Martin Treusch von Buttlar Date: Sat, 20 May 2017 13:11:27 +0200 Subject: add more tests for 'ponzu new' - run with 'go test . -run Check -v' --- cmd/ponzu/new_test.go | 41 ++++++++++++++++++++++++++++------------- 1 file 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) } -- cgit v1.2.3