Merge pull request #1785 from r2d4/lint

go lint/vet fixes
pull/1807/head
Matt Rickard 2017-08-09 10:44:03 -07:00 committed by GitHub
commit 245c4a04de
4 changed files with 37 additions and 31 deletions

View File

@ -59,28 +59,33 @@ var configTestCases = []configTestCase{
} }
func TestHiddenPrint(t *testing.T) { func TestHiddenPrint(t *testing.T) {
testString := "gabbagabbahey" testCases := []struct {
b := new(bytes.Buffer) TestString string
_, err := b.WriteString(fmt.Sprintf("%s\r\n", testString)) // you need the \r! Verbose bool
if err != nil { ShouldError bool
t.Errorf("Could not prepare bytestring") }{
{
TestString: "gabbagabbahey",
},
{
TestString: "gabbagabbahey",
Verbose: true,
},
} }
result, err := concealableAskForStaticValue(b, "hello", true) for _, test := range testCases {
if result != testString { b := new(bytes.Buffer)
t.Errorf("Result %s not match %s", result, testString) _, err := b.WriteString(fmt.Sprintf("%s\r\n", test.TestString)) // you need the \r!
} if err != nil {
} t.Errorf("Could not prepare bytestring")
}
func TestVerbosePrint(t *testing.T) { result, err := concealableAskForStaticValue(b, "hello", false)
testString := "gabbagabbahey" if err != nil && !test.ShouldError {
b := new(bytes.Buffer) t.Errorf("Error asking for concealable static value: %s", err)
_, err := b.WriteString(fmt.Sprintf("%s\r\n", testString)) // you need the \r! continue
if err != nil { }
t.Errorf("Could not prepare bytestring") if result != test.TestString {
} t.Errorf("Result %s not match %s", result, test.TestString)
result, err := concealableAskForStaticValue(b, "hello", false) }
if result != testString {
t.Errorf("Result %s not match %s", result, testString)
} }
} }

View File

@ -158,7 +158,7 @@ func TestKubectlDownloadMsg(t *testing.T) {
t.Errorf("Got output, but kubectl binary was found") t.Errorf("Got output, but kubectl binary was found")
} }
if !strings.Contains(actual, test.matches) { 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)
} }
}) })
} }

View File

@ -29,6 +29,7 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
"k8s.io/minikube/pkg/minikube/assets" "k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/util"
) )
// SSHSession provides methods for running commands on a host. // 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 { func DeleteAddon(a *assets.Addon, client *ssh.Client) error {
var err error m := util.MultiError{}
for _, f := range a.Assets { for _, f := range a.Assets {
if err := DeleteFile(f, client); err != nil { 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 { func TransferAddon(a *assets.Addon, client *ssh.Client) error {
var err error m := util.MultiError{}
for _, f := range a.Assets { for _, f := range a.Assets {
if err := TransferFile(f, client); err != nil { 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 { func TransferFile(f assets.CopyableFile, client *ssh.Client) error {

View File

@ -85,7 +85,7 @@ func TestShouldCacheMinikubeISO(t *testing.T) {
for input, expected := range tests { for input, expected := range tests {
if out := dler.ShouldCacheMinikubeISO(input); out != expected { 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 expected := false
if out := dler.IsMinikubeISOCached(testFileURI); out != expected { 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))) ioutil.WriteFile(filepath.Join(constants.GetMinipath(), "cache", "iso", "minikube-test.iso"), []byte(testISOString), os.FileMode(int(0644)))
expected = true expected = true
if out := dler.IsMinikubeISOCached(testFileURI); out != expected { 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)
} }
} }