diff --git a/pkg/minikube/out/register/json_test.go b/pkg/minikube/out/register/json_test.go index 7523ce0c6261..0d1fb3a20843 100644 --- a/pkg/minikube/out/register/json_test.go +++ b/pkg/minikube/out/register/json_test.go @@ -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" } diff --git a/test/integration/json_output_test.go b/test/integration/json_output_test.go index 1d469946edd8..38db922a7d8f 100644 --- a/test/integration/json_output_test.go +++ b/test/integration/json_output_test.go @@ -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...))