fix unit test

pull/8796/head
Priya Wadhwa 2020-07-21 18:22:09 -04:00
parent 8bc875d520
commit 6a33c03df2
2 changed files with 10 additions and 3 deletions

View File

@ -97,15 +97,20 @@ func TestErrorExitCode(t *testing.T) {
}
PrintErrorExitCode("error", 5, map[string]string{"a": "b"}, map[string]string{"c": "d"})
actual := buf.String()
if actual != expected {
t.Fatalf("expected didn't match actual:\nExpected:\n%v\n\nActual:\n%v", expected, actual)
}
}
func TestWarning(t *testing.T) {
expected := `{"data":{"message":"warning"},"datacontenttype":"application/json","id":"random-id","source":"https://minikube.sigs.k8s.io/","specversion":"1.0","type":"io.k8s.sigs.minikube.warning"}`
expected += "\n"
buf := bytes.NewBuffer([]byte{})
outputFile = buf
defer func() { outputFile = os.Stdout }()
OutputFile = buf
defer func() { OutputFile = os.Stdout }()
getUUID = func() string {
GetUUID = func() string {
return "random-id"
}

View File

@ -65,6 +65,8 @@ func TestJSONOutputError(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), Minutes(2))
defer Cleanup(t, profile, cancel)
// force a failure via --driver=fail so that we can make sure errors
// are printed as expected
startArgs := []string{"start", "-p", profile, "--memory=2200", "--output=json", "--wait=true", "--driver=fail"}
rr, err := Run(t, exec.CommandContext(ctx, Target(), startArgs...))