diff options
Diffstat (limited to 'src/pkg/os/user/user_test.go')
-rw-r--r-- | src/pkg/os/user/user_test.go | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/src/pkg/os/user/user_test.go b/src/pkg/os/user/user_test.go index b812ebce7..444a9aacd 100644 --- a/src/pkg/os/user/user_test.go +++ b/src/pkg/os/user/user_test.go @@ -5,41 +5,34 @@ package user import ( - "os" "runtime" "testing" ) -func skip(t *testing.T) bool { +func check(t *testing.T) { if !implemented { - t.Logf("user: not implemented; skipping tests") - return true + t.Skip("user: not implemented; skipping tests") } - switch runtime.GOOS { case "linux", "freebsd", "darwin", "windows": - return false + // test supported + default: + t.Skipf("user: Lookup not implemented on %q; skipping test", runtime.GOOS) } - - t.Logf("user: Lookup not implemented on %s; skipping test", runtime.GOOS) - return true } func TestCurrent(t *testing.T) { - if skip(t) { - return - } + check(t) u, err := Current() if err != nil { t.Fatalf("Current: %v", err) } - fi, err := os.Stat(u.HomeDir) - if err != nil || !fi.IsDir() { - t.Errorf("expected a valid HomeDir; stat(%q): err=%v", u.HomeDir, err) + if u.HomeDir == "" { + t.Errorf("didn't get a HomeDir") } if u.Username == "" { - t.Fatalf("didn't get a username") + t.Errorf("didn't get a username") } } @@ -55,8 +48,7 @@ func compare(t *testing.T, want, got *User) { } // TODO(brainman): fix it once we know how. if runtime.GOOS == "windows" { - t.Log("skipping Gid and HomeDir comparisons") - return + t.Skip("skipping Gid and HomeDir comparisons") } if want.Gid != got.Gid { t.Errorf("got Gid=%q; want %q", got.Gid, want.Gid) @@ -67,9 +59,7 @@ func compare(t *testing.T, want, got *User) { } func TestLookup(t *testing.T) { - if skip(t) { - return - } + check(t) want, err := Current() if err != nil { @@ -83,9 +73,7 @@ func TestLookup(t *testing.T) { } func TestLookupId(t *testing.T) { - if skip(t) { - return - } + check(t) want, err := Current() if err != nil { |