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

Function TestCommandVerboseStatusWritesOnlyWhenVerbose

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

Source from the content-addressed store, hash-verified

220}
221
222func TestCommandVerboseStatusWritesOnlyWhenVerbose(t *testing.T) {
223 var stderr bytes.Buffer
224 cmd := &cobra.Command{}
225 cmd.Flags().Bool("verbose", false, "")
226 cmd.SetErr(&stderr)
227
228 commandVerboseStatus(cmd, "done %s", "quietly")
229 if got := stderr.String(); got != "" {
230 t.Fatalf("stderr = %q, want empty", got)
231 }
232
233 if err := cmd.Flags().Set("verbose", "true"); err != nil {
234 t.Fatalf("set verbose: %v", err)
235 }
236 commandVerboseStatus(cmd, "done %s", "loudly")
237 if got, want := stderr.String(), "done loudly\n"; got != want {
238 t.Fatalf("stderr = %q, want %q", got, want)
239 }
240}
241
242func TestRenderCommandErrorWritesTextErrorToStderr(t *testing.T) {
243 var stdout bytes.Buffer

Callers

nothing calls this directly

Calls 1

commandVerboseStatusFunction · 0.85

Tested by

no test coverage detected