MCPcopy Create free account
hub / github.com/dropbox/dbxcli / TestRenderCommandErrorWithJSONForcesJSONError

Function TestRenderCommandErrorWithJSONForcesJSONError

cmd/output_test.go:698–718  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

696}
697
698func 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
720func TestNewJSONOperationOutputNormalizesWarnings(t *testing.T) {
721 got := newJSONOperationOutput(

Callers

nothing calls this directly

Calls 2

decodeJSONErrorResponseFunction · 0.85

Tested by

no test coverage detected