go lint/vet fixes
parent
dde62b5635
commit
5531a63b8d
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue