(t *testing.T)
| 202 | } |
| 203 | |
| 204 | func TestCpJSONOutputsRelocationResults(t *testing.T) { |
| 205 | stubFilesClient(t, &mockFilesClient{ |
| 206 | getMetadataFn: func(arg *files.GetMetadataArg) (files.IsMetadata, error) { |
| 207 | return nil, fmt.Errorf("path/not_found/") |
| 208 | }, |
| 209 | copyV2Fn: func(arg *files.RelocationArg) (*files.RelocationResult, error) { |
| 210 | metadata := files.NewFileMetadata("file-copy.txt", "id:file-copy", dropbox.DBXTime(time.Time{}), dropbox.DBXTime(time.Time{}), "rev-copy", 42) |
| 211 | metadata.PathDisplay = arg.ToPath |
| 212 | metadata.PathLower = strings.ToLower(arg.ToPath) |
| 213 | return files.NewRelocationResult(metadata), nil |
| 214 | }, |
| 215 | }) |
| 216 | |
| 217 | var stdout bytes.Buffer |
| 218 | cmd := newRelocationTestCommand(&stdout, nil) |
| 219 | |
| 220 | if err := cp(cmd, []string{"/src/file.txt", "/dest/file-copy.txt"}); err != nil { |
| 221 | t.Fatalf("cp error: %v", err) |
| 222 | } |
| 223 | |
| 224 | got := decodeRelocationOutput(t, stdout.Bytes()) |
| 225 | if len(got.Results) != 1 { |
| 226 | t.Fatalf("results = %d, want 1", len(got.Results)) |
| 227 | } |
| 228 | result := got.Results[0] |
| 229 | if result.Input.FromPath != "/src/file.txt" || result.Input.ToPath != "/dest/file-copy.txt" { |
| 230 | t.Fatalf("input = %#v, want source and destination", result.Input) |
| 231 | } |
| 232 | if result.Result.Type != "file" || result.Result.PathDisplay != "/dest/file-copy.txt" { |
| 233 | t.Fatalf("result = %#v, want copied file metadata", result.Result) |
| 234 | } |
| 235 | if result.Result.Size == nil || *result.Result.Size != 42 { |
| 236 | t.Fatalf("size = %#v, want 42", result.Result.Size) |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | func TestCpJSONMultipleSourcesOutputsMultipleResults(t *testing.T) { |
| 241 | stubFilesClient(t, &mockFilesClient{ |
nothing calls this directly
no test coverage detected