From 887a66459a1dc231812202a45316e77808df2c18 Mon Sep 17 00:00:00 2001 From: avaid96 Date: Tue, 12 Jul 2016 10:23:05 -0700 Subject: [PATCH] I think OSX tests were failing because it was a list against an empty keychain, checking whether that is the case by filling it first Signed-off-by: avaid96 --- osxkeychain/osxkeychain_darwin.go | 1 + osxkeychain/osxkeychain_darwin_test.go | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/osxkeychain/osxkeychain_darwin.go b/osxkeychain/osxkeychain_darwin.go index 28c316d..267142a 100644 --- a/osxkeychain/osxkeychain_darwin.go +++ b/osxkeychain/osxkeychain_darwin.go @@ -104,6 +104,7 @@ func (h Osxkeychain) List() ([]string, []string, error) { if errMsg != nil { defer C.free(unsafe.Pointer(errMsg)) goMsg := C.GoString(errMsg) + goMsg = "Error is here" return nil, nil, errors.New(goMsg) } var listLen int diff --git a/osxkeychain/osxkeychain_darwin_test.go b/osxkeychain/osxkeychain_darwin_test.go index 5d21023..bfaa69c 100644 --- a/osxkeychain/osxkeychain_darwin_test.go +++ b/osxkeychain/osxkeychain_darwin_test.go @@ -11,7 +11,11 @@ func TestOSXKeychainHelper(t *testing.T) { Username: "foobar", Secret: "foobarbaz", } - + creds1 := &credentials.Credentials{ + ServerURL: "https://foobar.docker.io:2376/v2", + Username: "foobarbaz", + Secret: "foobar", + } helper := Osxkeychain{} if err := helper.Add(creds); err != nil { t.Fatal(err) @@ -33,17 +37,18 @@ func TestOSXKeychainHelper(t *testing.T) { if err := helper.Delete(creds.ServerURL); err != nil { t.Fatal(err) } - + helper.Add(creds); + defer helper.Delete(creds.ServerURL) paths, accts, err := helper.List() if err != nil || len(paths) == 0 || len(accts) == 0 { t.Fatal(err) } - helper.Add(creds) + helper.Add(creds1) newpaths, newaccts, err := helper.List() if len(newpaths)-len(paths) != 1 || len(newaccts)-len(accts) != 1 { t.Fatal(err) } - helper.Delete(creds.ServerURL) + helper.Delete(creds1.ServerURL) } func TestMissingCredentials(t *testing.T) {