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

Function TestRenderCommandErrorPreservesExplicitMemberIDDetails

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

Source from the content-addressed store, hash-verified

437}
438
439func TestRenderCommandErrorPreservesExplicitMemberIDDetails(t *testing.T) {
440 var stdout bytes.Buffer
441 var stderr bytes.Buffer
442 cmd := &cobra.Command{Use: "ls"}
443 cmd.SetOut(&stdout)
444 cmd.SetErr(&stderr)
445 cmd.Flags().String(outputFlag, "json", "")
446 cmd.Flags().String("as-member", "dbmid:context", "")
447
448 err := withJSONErrorDetails(
449 fmt.Errorf("get metadata: %w", files.GetMetadataAPIError{APIError: dropbox.APIError{ErrorSummary: "path/not_found/"}}),
450 memberIDErrorDetails("dbmid:explicit"),
451 )
452 renderCommandError(cmd, err)
453
454 if got := stderr.String(); got != "" {
455 t.Fatalf("stderr = %q, want empty", got)
456 }
457 got := decodeJSONErrorResponse(t, stdout.String())
458 if got.Error.Details["member_id"] != "dbmid:explicit" {
459 t.Fatalf("details = %+v, want explicit member_id", got.Error.Details)
460 }
461}
462
463func TestRenderCommandErrorDoesNotIncludeAsMemberForLocalValidation(t *testing.T) {
464 var stdout bytes.Buffer

Callers

nothing calls this directly

Calls 4

withJSONErrorDetailsFunction · 0.85
memberIDErrorDetailsFunction · 0.85
renderCommandErrorFunction · 0.85
decodeJSONErrorResponseFunction · 0.85

Tested by

no test coverage detected