Skip to content

Commit

Permalink
Fix unittests.
Browse files Browse the repository at this point in the history
  • Loading branch information
rgooch committed Mar 9, 2024
1 parent 8ee10ac commit 62c4d88
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
10 changes: 2 additions & 8 deletions cmd/keymaster/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down
15 changes: 6 additions & 9 deletions lib/client/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io/ioutil"
"net"
"os"
"os/user"
"testing"

"github.com/Cloud-Foundations/golib/pkg/log/testlogger"
Expand Down Expand Up @@ -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")
}
}

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 62c4d88

Please sign in to comment.