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

Function TestRmJSONErrorWritesNoOutput

cmd/rm_test.go:627–649  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

625}
626
627func TestRmJSONErrorWritesNoOutput(t *testing.T) {
628 cmd, stdout := testRmCmd(t)
629 setRmOutputJSON(t, cmd)
630
631 mock := &mockFilesClient{
632 getMetadataFn: func(arg *files.GetMetadataArg) (files.IsMetadata, error) {
633 return nil, errors.New("metadata failed")
634 },
635 }
636 stubFilesClient(t, mock)
637
638 err := rm(cmd, []string{"/File.txt"})
639 if err == nil {
640 t.Fatal("expected rm error")
641 }
642 details := jsonErrorDetails(err)
643 if details["operation"] != "delete" || details["path"] != "/File.txt" {
644 t.Fatalf("details = %#v, want delete operation and path", details)
645 }
646 if got := stdout.String(); got != "" {
647 t.Fatalf("stdout = %q, want empty output on error", got)
648 }
649}
650
651func TestRmCommandSupportsStructuredOutput(t *testing.T) {
652 if !commandSupportsStructuredOutput(rmCmd) {

Callers

nothing calls this directly

Calls 5

testRmCmdFunction · 0.85
setRmOutputJSONFunction · 0.85
stubFilesClientFunction · 0.85
rmFunction · 0.85
jsonErrorDetailsFunction · 0.85

Tested by

no test coverage detected