From 08af0700bf4ca223b33e0bb76d6086779553d7e8 Mon Sep 17 00:00:00 2001 From: Ibrahim AshShohail Date: Fri, 4 Aug 2017 16:21:05 +0300 Subject: [PATCH] fix tests Signed-off-by: Ibrahim AshShohail --- context_test.go | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/context_test.go b/context_test.go index e522d25b4d..503ed1beaf 100644 --- a/context_test.go +++ b/context_test.go @@ -314,23 +314,16 @@ func TestDetectProjectGOPATH(t *testing.T) { h := test.NewHelper(t) defer h.Cleanup() - h.TempDir("go") - h.TempDir("go-two") + h.TempDir(filepath.Join("sym", "symlink")) + h.TempDir(filepath.Join("go", "src", "sym", "path")) + h.TempDir(filepath.Join("go", "src", "real", "path")) + h.TempDir(filepath.Join("go-two", "src", "real", "path")) + h.TempDir(filepath.Join("go-two", "src", "sym")) ctx := &Ctx{ GOPATHs: []string{h.Path("go"), h.Path("go-two")}, } - h.TempDir("go/src/real/path") - - // Another directory used as a GOPATH - h.TempDir("go-two/src/sym") - - h.TempDir(filepath.Join(".", "sym/symlink")) // Directory for symlinks - h.TempDir(filepath.Join("go", "src", "sym", "path")) - h.TempDir(filepath.Join("go", "src", " real", "path")) - h.TempDir(filepath.Join("go-two", "src", "real", "path")) - testcases := []struct { name string root string @@ -383,7 +376,7 @@ func TestDetectProjectGOPATH(t *testing.T) { { name: "AbsRoot-is-a-symlink-to-ResolvedAbsRoot", root: filepath.Join(h.Path("."), "sym", "symlink"), - resolvedRoot: filepath.Join(ctx.GOPATHs[0], "src", " real", "path"), + resolvedRoot: filepath.Join(ctx.GOPATHs[0], "src", "real", "path"), GOPATH: ctx.GOPATHs[0], }, } @@ -412,36 +405,33 @@ func TestDetectGOPATH(t *testing.T) { th := test.NewHelper(t) defer th.Cleanup() - th.TempDir("go") - th.TempDir("gotwo") + th.TempDir(filepath.Join("code", "src", "github.com", "username", "package")) + th.TempDir(filepath.Join("go", "src", "github.com", "username", "package")) + th.TempDir(filepath.Join("gotwo", "src", "github.com", "username", "package")) ctx := &Ctx{GOPATHs: []string{ th.Path("go"), th.Path("gotwo"), }} - th.TempDir(filepath.Join("code", "src", "github.com", "username", "package")) - th.TempDir(filepath.Join("go", "src", "github.com", "username", "package")) - th.TempDir(filepath.Join("gotwo", "src", "github.com", "username", "package")) - testcases := []struct { GOPATH string path string err bool }{ - {th.Path("go"), filepath.Join(th.Path("go"), "src/github.com/username/package"), false}, - {th.Path("go"), filepath.Join(th.Path("go"), "src/github.com/username/package"), false}, - {th.Path("gotwo"), filepath.Join(th.Path("gotwo"), "src/github.com/username/package"), false}, - {"", filepath.Join(th.Path("."), "code/src/github.com/username/package"), true}, + {th.Path("go"), th.Path(filepath.Join("go", "src", "github.com", "username", "package")), false}, + {th.Path("go"), th.Path(filepath.Join("go", "src", "github.com", "username", "package")), false}, + {th.Path("gotwo"), th.Path(filepath.Join("gotwo", "src", "github.com", "username", "package")), false}, + {"", th.Path(filepath.Join("code", "src", "github.com", "username", "package")), true}, } for _, tc := range testcases { GOPATH, err := ctx.detectGOPATH(tc.path) if tc.err && err == nil { - t.Error("Expected error but got none") + t.Error("expected error but got none") } if GOPATH != tc.GOPATH { - t.Errorf("Expected GOPATH to be %s, got %s", GOPATH, tc.GOPATH) + t.Errorf("expected GOPATH to be %s, got %s", GOPATH, tc.GOPATH) } } }