Skip to content

Commit 6a33c03

Browse files
author
Priya Wadhwa
committed
fix unit test
1 parent 8bc875d commit 6a33c03

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

pkg/minikube/out/register/json_test.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,20 @@ func TestErrorExitCode(t *testing.T) {
9797
}
9898

9999
PrintErrorExitCode("error", 5, map[string]string{"a": "b"}, map[string]string{"c": "d"})
100+
actual := buf.String()
101+
if actual != expected {
102+
t.Fatalf("expected didn't match actual:\nExpected:\n%v\n\nActual:\n%v", expected, actual)
103+
}
104+
}
100105
func TestWarning(t *testing.T) {
101106
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"}`
102107
expected += "\n"
103108

104109
buf := bytes.NewBuffer([]byte{})
105-
outputFile = buf
106-
defer func() { outputFile = os.Stdout }()
110+
OutputFile = buf
111+
defer func() { OutputFile = os.Stdout }()
107112

108-
getUUID = func() string {
113+
GetUUID = func() string {
109114
return "random-id"
110115
}
111116

test/integration/json_output_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ func TestJSONOutputError(t *testing.T) {
6565
ctx, cancel := context.WithTimeout(context.Background(), Minutes(2))
6666
defer Cleanup(t, profile, cancel)
6767

68+
// force a failure via --driver=fail so that we can make sure errors
69+
// are printed as expected
6870
startArgs := []string{"start", "-p", profile, "--memory=2200", "--output=json", "--wait=true", "--driver=fail"}
6971

7072
rr, err := Run(t, exec.CommandContext(ctx, Target(), startArgs...))

0 commit comments

Comments
 (0)