diff --git a/cmd/keymaster/main_test.go b/cmd/keymaster/main_test.go index cfc2656..ed13f4b 100644 --- a/cmd/keymaster/main_test.go +++ b/cmd/keymaster/main_test.go @@ -20,6 +20,7 @@ import ( "github.com/Cloud-Foundations/golib/pkg/log/testlogger" "github.com/Cloud-Foundations/keymaster/lib/client/config" + "github.com/Cloud-Foundations/keymaster/lib/client/util" "github.com/Cloud-Foundations/keymaster/lib/webapi/v0/proto" ) @@ -71,13 +72,6 @@ func init() { time.Sleep(20 * time.Millisecond) } -func TestGetCertFromTargetUrlsSuccessOneURL(t *testing.T) { - _, _, err := getUserNameAndHomeDir(testlogger.New(t)) - if err != nil { - t.Fatal(err) - } -} - func TestGetHttpClient(t *testing.T) { client, err := getHttpClient(nil, testlogger.New(t)) if err != nil { @@ -171,7 +165,7 @@ func TestMost(t *testing.T) { if err != nil { t.Fatal(err) } - userName, homeDir, err := getUserNameAndHomeDir(logger) + userName, homeDir, err := util.GetUserNameAndHomeDir() if err != nil { t.Fatal(err) } diff --git a/lib/client/util/util_test.go b/lib/client/util/util_test.go index e799975..64b3333 100644 --- a/lib/client/util/util_test.go +++ b/lib/client/util/util_test.go @@ -6,7 +6,6 @@ import ( "io/ioutil" "net" "os" - "os/user" "testing" "github.com/Cloud-Foundations/golib/pkg/log/testlogger" @@ -44,18 +43,15 @@ func TestGenKeyPairFailNoPerms(t *testing.T) { } func TestGetUserHomeDirSuccess(t *testing.T) { - usr, err := user.Current() + userName, homeDir, err := GetUserNameAndHomeDir() if err != nil { - t.Logf("cannot get current user info") t.Fatal(err) } - homeDir, err := GetUserHomeDir(usr) - if err != nil { - t.Fatal(err) + if len(userName) < 1 { + t.Fatal("invalid userName") } if len(homeDir) < 1 { - t.Fatal("invalid homedir") - + t.Fatal("invalid homeDir") } } @@ -89,7 +85,8 @@ func TestGetParseURLEnvVariable(t *testing.T) { } // ------------WARN-------- Next name copied from https://github.com/howeyc/gopass/blob/master/pass_test.go for using -// gopass checks +// +// gopass checks func TestPipe(t *testing.T) { _, err := pipeToStdin("password\n") if err != nil {