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

Function TestRenderCommandErrorWritesTextErrorToStderr

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

Source from the content-addressed store, hash-verified

240}
241
242func TestRenderCommandErrorWritesTextErrorToStderr(t *testing.T) {
243 var stdout bytes.Buffer
244 var stderr bytes.Buffer
245 cmd := &cobra.Command{}
246 cmd.SetOut(&stdout)
247 cmd.SetErr(&stderr)
248 cmd.Flags().String(outputFlag, "text", "")
249
250 renderCommandError(cmd, errors.New("failed"))
251
252 if got := stdout.String(); got != "" {
253 t.Fatalf("stdout = %q, want empty", got)
254 }
255 if got, want := stderr.String(), "Error: failed\n"; got != want {
256 t.Fatalf("stderr = %q, want %q", got, want)
257 }
258}
259
260func TestRenderCommandErrorTextUnknownCommandIncludesUsageHint(t *testing.T) {
261 var stdout bytes.Buffer

Callers

nothing calls this directly

Calls 1

renderCommandErrorFunction · 0.85

Tested by

no test coverage detected