(t *testing.T)
| 625 | } |
| 626 | |
| 627 | func 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 | |
| 651 | func TestRmCommandSupportsStructuredOutput(t *testing.T) { |
| 652 | if !commandSupportsStructuredOutput(rmCmd) { |
nothing calls this directly
no test coverage detected