(t *testing.T)
| 82 | } |
| 83 | |
| 84 | func TestMvJSONOutputsRelocationResults(t *testing.T) { |
| 85 | stubFilesClient(t, &mockFilesClient{ |
| 86 | getMetadataFn: func(arg *files.GetMetadataArg) (files.IsMetadata, error) { |
| 87 | return nil, fmt.Errorf("path/not_found/") |
| 88 | }, |
| 89 | moveV2Fn: func(arg *files.RelocationArg) (*files.RelocationResult, error) { |
| 90 | metadata := files.NewFileMetadata("file-moved.txt", "id:file-moved", dropbox.DBXTime(time.Time{}), dropbox.DBXTime(time.Time{}), "rev-moved", 64) |
| 91 | metadata.PathDisplay = arg.ToPath |
| 92 | metadata.PathLower = strings.ToLower(arg.ToPath) |
| 93 | return files.NewRelocationResult(metadata), nil |
| 94 | }, |
| 95 | }) |
| 96 | |
| 97 | var stdout bytes.Buffer |
| 98 | cmd := newRelocationTestCommand(&stdout, nil) |
| 99 | |
| 100 | if err := mv(cmd, []string{"/src/file.txt", "/dest/file-moved.txt"}); err != nil { |
| 101 | t.Fatalf("mv error: %v", err) |
| 102 | } |
| 103 | |
| 104 | got := decodeRelocationOutput(t, stdout.Bytes()) |
| 105 | if len(got.Results) != 1 { |
| 106 | t.Fatalf("results = %d, want 1", len(got.Results)) |
| 107 | } |
| 108 | result := got.Results[0] |
| 109 | if result.Input.FromPath != "/src/file.txt" || result.Input.ToPath != "/dest/file-moved.txt" { |
| 110 | t.Fatalf("input = %#v, want source and destination", result.Input) |
| 111 | } |
| 112 | if result.Result.Type != "file" || result.Result.PathDisplay != "/dest/file-moved.txt" { |
| 113 | t.Fatalf("result = %#v, want moved file metadata", result.Result) |
| 114 | } |
| 115 | if result.Result.Size == nil || *result.Result.Size != 64 { |
| 116 | t.Fatalf("size = %#v, want 64", result.Result.Size) |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | func TestMvJSONMultipleSourcesOutputsMultipleResults(t *testing.T) { |
| 121 | stubFilesClient(t, &mockFilesClient{ |
nothing calls this directly
no test coverage detected