(t *testing.T)
| 696 | } |
| 697 | |
| 698 | func TestRenderCommandErrorWithJSONForcesJSONError(t *testing.T) { |
| 699 | var stdout bytes.Buffer |
| 700 | var stderr bytes.Buffer |
| 701 | cmd := &cobra.Command{} |
| 702 | cmd.SetOut(&stdout) |
| 703 | cmd.SetErr(&stderr) |
| 704 | cmd.Flags().String(outputFlag, "text", "") |
| 705 | |
| 706 | renderCommandErrorWithJSON(cmd, errors.New(`unknown command "missing" for "dbxcli"`), true) |
| 707 | |
| 708 | if got := stderr.String(); got != "" { |
| 709 | t.Fatalf("stderr = %q, want empty", got) |
| 710 | } |
| 711 | got := decodeJSONErrorResponse(t, stdout.String()) |
| 712 | if got.Error.Code != "unknown_command" { |
| 713 | t.Fatalf("code = %q, want unknown_command", got.Error.Code) |
| 714 | } |
| 715 | if len(got.Warnings) != 0 { |
| 716 | t.Fatalf("warnings = %+v, want empty", got.Warnings) |
| 717 | } |
| 718 | } |
| 719 | |
| 720 | func TestNewJSONOperationOutputNormalizesWarnings(t *testing.T) { |
| 721 | got := newJSONOperationOutput( |
nothing calls this directly
no test coverage detected