(t *testing.T)
| 56 | } |
| 57 | |
| 58 | func TestMvMoveErrorIncludesAPIError(t *testing.T) { |
| 59 | mock := &mockFilesClient{ |
| 60 | getMetadataFn: func(arg *files.GetMetadataArg) (files.IsMetadata, error) { |
| 61 | return nil, fmt.Errorf("path/not_found/") |
| 62 | }, |
| 63 | moveV2Fn: func(arg *files.RelocationArg) (*files.RelocationResult, error) { |
| 64 | return nil, fmt.Errorf("path/malformed_path/") |
| 65 | }, |
| 66 | } |
| 67 | stubFilesClient(t, mock) |
| 68 | |
| 69 | var err error |
| 70 | stderr := captureStderr(t, func() { |
| 71 | err = mv(mvCmd, []string{"/src/file.txt", "/dest/file.txt"}) |
| 72 | }) |
| 73 | if err == nil { |
| 74 | t.Fatal("expected mv error") |
| 75 | } |
| 76 | if !strings.Contains(stderr, `move "/src/file.txt" to "/dest/file.txt": path/malformed_path/`) { |
| 77 | t.Errorf("stderr = %q, want move path and API error", stderr) |
| 78 | } |
| 79 | if strings.Contains(stderr, "&{{") { |
| 80 | t.Errorf("stderr still contains formatted relocation arg: %q", stderr) |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | func TestMvJSONOutputsRelocationResults(t *testing.T) { |
| 85 | stubFilesClient(t, &mockFilesClient{ |
nothing calls this directly
no test coverage detected