diff --git a/cmd/minikube/cmd/config/config_test.go b/cmd/minikube/cmd/config/config_test.go index d00b09e6a7..4f86544b9c 100644 --- a/cmd/minikube/cmd/config/config_test.go +++ b/cmd/minikube/cmd/config/config_test.go @@ -59,28 +59,33 @@ var configTestCases = []configTestCase{ } func TestHiddenPrint(t *testing.T) { - testString := "gabbagabbahey" - b := new(bytes.Buffer) - _, err := b.WriteString(fmt.Sprintf("%s\r\n", testString)) // you need the \r! - if err != nil { - t.Errorf("Could not prepare bytestring") + testCases := []struct { + TestString string + Verbose bool + ShouldError bool + }{ + { + TestString: "gabbagabbahey", + }, + { + TestString: "gabbagabbahey", + Verbose: true, + }, } - result, err := concealableAskForStaticValue(b, "hello", true) - if result != testString { - t.Errorf("Result %s not match %s", result, testString) - } -} - -func TestVerbosePrint(t *testing.T) { - testString := "gabbagabbahey" - b := new(bytes.Buffer) - _, err := b.WriteString(fmt.Sprintf("%s\r\n", testString)) // you need the \r! - if err != nil { - t.Errorf("Could not prepare bytestring") - } - result, err := concealableAskForStaticValue(b, "hello", false) - if result != testString { - t.Errorf("Result %s not match %s", result, testString) + for _, test := range testCases { + b := new(bytes.Buffer) + _, err := b.WriteString(fmt.Sprintf("%s\r\n", test.TestString)) // you need the \r! + if err != nil { + t.Errorf("Could not prepare bytestring") + } + result, err := concealableAskForStaticValue(b, "hello", false) + if err != nil && !test.ShouldError { + t.Errorf("Error asking for concealable static value: %s", err) + continue + } + if result != test.TestString { + t.Errorf("Result %s not match %s", result, test.TestString) + } } } diff --git a/cmd/util/util_test.go b/cmd/util/util_test.go index bded1c00fc..172a49789a 100644 --- a/cmd/util/util_test.go +++ b/cmd/util/util_test.go @@ -158,7 +158,7 @@ func TestKubectlDownloadMsg(t *testing.T) { t.Errorf("Got output, but kubectl binary was found") } if !strings.Contains(actual, test.matches) { - t.Errorf("Output did not contain substring expected got output %s") + t.Errorf("Output did not contain substring expected got output %s", actual) } }) } diff --git a/pkg/minikube/sshutil/sshutil.go b/pkg/minikube/sshutil/sshutil.go index 41a036dbf5..ffd769f2ac 100644 --- a/pkg/minikube/sshutil/sshutil.go +++ b/pkg/minikube/sshutil/sshutil.go @@ -29,6 +29,7 @@ import ( "github.com/pkg/errors" "golang.org/x/crypto/ssh" "k8s.io/minikube/pkg/minikube/assets" + "k8s.io/minikube/pkg/util" ) // SSHSession provides methods for running commands on a host. @@ -63,23 +64,23 @@ func NewSSHClient(d drivers.Driver) (*ssh.Client, error) { } func DeleteAddon(a *assets.Addon, client *ssh.Client) error { - var err error + m := util.MultiError{} for _, f := range a.Assets { if err := DeleteFile(f, client); err != nil { - err = errors.Wrap(err, "") + m.Collect(err) } } - return err + return m.ToError() } func TransferAddon(a *assets.Addon, client *ssh.Client) error { - var err error + m := util.MultiError{} for _, f := range a.Assets { if err := TransferFile(f, client); err != nil { - errors.Wrap(err, "") + m.Collect(err) } } - return err + return m.ToError() } func TransferFile(f assets.CopyableFile, client *ssh.Client) error { diff --git a/pkg/util/downloader_test.go b/pkg/util/downloader_test.go index dad6ad9979..933c23ddf1 100644 --- a/pkg/util/downloader_test.go +++ b/pkg/util/downloader_test.go @@ -85,7 +85,7 @@ func TestShouldCacheMinikubeISO(t *testing.T) { for input, expected := range tests { if out := dler.ShouldCacheMinikubeISO(input); out != expected { - t.Fatalf("Expected ShouldCacheMinikubeISO with input %s to return %d but instead got: %t", input, expected, out) + t.Fatalf("Expected ShouldCacheMinikubeISO with input %s to return %t but instead got: %t", input, expected, out) } } } @@ -100,14 +100,14 @@ func TestIsMinikubeISOCached(t *testing.T) { expected := false if out := dler.IsMinikubeISOCached(testFileURI); out != expected { - t.Fatalf("Expected IsMinikubeISOCached with input to return %s but instead got: %s", testFileURI, expected, out) + t.Fatalf("Expected IsMinikubeISOCached with input %s to return %t but instead got: %t", testFileURI, expected, out) } ioutil.WriteFile(filepath.Join(constants.GetMinipath(), "cache", "iso", "minikube-test.iso"), []byte(testISOString), os.FileMode(int(0644))) expected = true if out := dler.IsMinikubeISOCached(testFileURI); out != expected { - t.Fatalf("Expected IsMinikubeISOCached with input to return %s but instead got: %s", testFileURI, expected, out) + t.Fatalf("Expected IsMinikubeISOCached with input %s to return %t but instead got: %t", testFileURI, expected, out) } }