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

Function TestRenderCommandErrorIncludesCodedDetails

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

Source from the content-addressed store, hash-verified

349}
350
351func TestRenderCommandErrorIncludesCodedDetails(t *testing.T) {
352 var stdout bytes.Buffer
353 var stderr bytes.Buffer
354 cmd := &cobra.Command{Use: "mkdir"}
355 cmd.SetOut(&stdout)
356 cmd.SetErr(&stderr)
357 cmd.Flags().String(outputFlag, "json", "")
358
359 renderCommandError(cmd, pathConflictErrorWithPath("/file", "path exists and is not a folder: %s", "/file"))
360
361 if got := stderr.String(); got != "" {
362 t.Fatalf("stderr = %q, want empty", got)
363 }
364 got := decodeJSONErrorResponse(t, stdout.String())
365 if got.Error.Code != jsonErrorCodePathConflict {
366 t.Fatalf("code = %q, want %q", got.Error.Code, jsonErrorCodePathConflict)
367 }
368 if got.Error.Details["path"] != "/file" {
369 t.Fatalf("details = %+v, want path", got.Error.Details)
370 }
371}
372
373func TestRenderCommandErrorIncludesArgumentAndFlagDetails(t *testing.T) {
374 var stdout bytes.Buffer

Callers

nothing calls this directly

Calls 3

renderCommandErrorFunction · 0.85
decodeJSONErrorResponseFunction · 0.85

Tested by

no test coverage detected