1
// Copyright 2011 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
13
func skip(t *testing.T) bool {
15
t.Logf("user: not implemented; skipping tests")
20
case "linux", "freebsd", "darwin", "windows":
24
t.Logf("user: Lookup not implemented on %s; skipping test", runtime.GOOS)
28
func TestCurrent(t *testing.T) {
35
t.Fatalf("Current: %v", err)
37
fi, err := os.Stat(u.HomeDir)
38
if err != nil || !fi.IsDir() {
39
t.Errorf("expected a valid HomeDir; stat(%q): err=%v", u.HomeDir, err)
42
t.Fatalf("didn't get a username")
46
func compare(t *testing.T, want, got *User) {
47
if want.Uid != got.Uid {
48
t.Errorf("got Uid=%q; want %q", got.Uid, want.Uid)
50
if want.Username != got.Username {
51
t.Errorf("got Username=%q; want %q", got.Username, want.Username)
53
if want.Name != got.Name {
54
t.Errorf("got Name=%q; want %q", got.Name, want.Name)
56
// TODO(brainman): fix it once we know how.
57
if runtime.GOOS == "windows" {
58
t.Log("skipping Gid and HomeDir comparisons")
61
if want.Gid != got.Gid {
62
t.Errorf("got Gid=%q; want %q", got.Gid, want.Gid)
64
if want.HomeDir != got.HomeDir {
65
t.Errorf("got HomeDir=%q; want %q", got.HomeDir, want.HomeDir)
69
func TestLookup(t *testing.T) {
74
want, err := Current()
76
t.Fatalf("Current: %v", err)
78
got, err := Lookup(want.Username)
80
t.Fatalf("Lookup: %v", err)
85
func TestLookupId(t *testing.T) {
90
want, err := Current()
92
t.Fatalf("Current: %v", err)
94
got, err := LookupId(want.Uid)
96
t.Fatalf("LookupId: %v", err)