Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Priya Wadhwa committed Jul 21, 2020
1 parent 8bc875d commit 6a33c03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/minikube/out/register/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
2 changes: 2 additions & 0 deletions test/integration/json_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...))
Expand Down

0 comments on commit 6a33c03

Please sign in to comment.