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

Function TestCommandOutputHonorsOutputJSON

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

Source from the content-addressed store, hash-verified

65}
66
67func TestCommandOutputHonorsOutputJSON(t *testing.T) {
68 var stdout bytes.Buffer
69 cmd := &cobra.Command{}
70 cmd.SetOut(&stdout)
71 cmd.Flags().String(outputFlag, "json", "")
72
73 out := commandOutput(cmd)
74 err := out.Render(func(w io.Writer) error {
75 t.Fatal("text renderer should not be called for JSON output")
76 return nil
77 }, struct {
78 Status string `json:"status"`
79 }{Status: "ok"})
80 if err != nil {
81 t.Fatalf("Render returned error: %v", err)
82 }
83
84 if got, want := stdout.String(), "{\"status\":\"ok\"}\n"; got != want {
85 t.Fatalf("stdout = %q, want %q", got, want)
86 }
87}
88
89func TestCommandOutputHonorsInheritedOutputJSON(t *testing.T) {
90 var stdout bytes.Buffer

Callers

nothing calls this directly

Calls 2

commandOutputFunction · 0.85
RenderMethod · 0.80

Tested by

no test coverage detected