fix: clean the output writter to avoid duplicates when testing for json output (#16619)

This commit is contained in:
Juana De La Cuesta
2023-03-29 12:05:23 +02:00
committed by GitHub
parent cd4c3c9eb4
commit 7f5d19e3a0

View File

@@ -52,7 +52,7 @@ func TestQuotaInspectCommand_Run(t *testing.T) {
// Create a quota to delete
qs := testQuotaSpec()
_, err := client.Quotas().Register(qs, nil)
must.NoError(t, err)
must.NoError(t, err, must.Sprint("unexpected error:", err))
// Delete a quota
code := cmd.Run([]string{"-address=" + url, qs.Name})
@@ -63,12 +63,13 @@ func TestQuotaInspectCommand_Run(t *testing.T) {
t.Fatalf("expected quota, got: %s", out)
}
ui.OutputWriter.Reset()
// List json
must.Zero(t, cmd.Run([]string{"-address=" + url, "-json", qs.Name}))
outJson := api.QuotaSpec{}
err = json.Unmarshal(ui.OutputWriter.Bytes(), &outJson)
must.NoError(t, err)
must.NoError(t, err, must.Sprint("unexpected error:", err))
ui.OutputWriter.Reset()