(t *testing.T)
| 332 | } |
| 333 | |
| 334 | func TestMvIfExistsSkipMultipleSourcesAppliesPerTarget(t *testing.T) { |
| 335 | var moved []string |
| 336 | stubFilesClient(t, &mockFilesClient{ |
| 337 | getMetadataFn: func(arg *files.GetMetadataArg) (files.IsMetadata, error) { |
| 338 | switch arg.Path { |
| 339 | case "/dest/a.txt": |
| 340 | return relocationTestFileMetadata(arg.Path, 1), nil |
| 341 | case "/dest/b.txt": |
| 342 | return nil, relocationTestGetMetadataNotFoundError() |
| 343 | default: |
| 344 | t.Fatalf("unexpected metadata path %q", arg.Path) |
| 345 | return nil, nil |
| 346 | } |
| 347 | }, |
| 348 | moveV2Fn: func(arg *files.RelocationArg) (*files.RelocationResult, error) { |
| 349 | moved = append(moved, arg.ToPath) |
| 350 | return files.NewRelocationResult(relocationTestFileMetadata(arg.ToPath, 2)), nil |
| 351 | }, |
| 352 | }) |
| 353 | |
| 354 | var stdout bytes.Buffer |
| 355 | cmd := newRelocationTestCommand(&stdout, nil) |
| 356 | if err := cmd.Flags().Set("if-exists", relocationIfExistsSkip); err != nil { |
| 357 | t.Fatal(err) |
| 358 | } |
| 359 | |
| 360 | if err := mv(cmd, []string{"/src/a.txt", "/src/b.txt", "/dest"}); err != nil { |
| 361 | t.Fatalf("mv error: %v", err) |
| 362 | } |
| 363 | if len(moved) != 1 || moved[0] != "/dest/b.txt" { |
| 364 | t.Fatalf("moved = %#v, want only /dest/b.txt", moved) |
| 365 | } |
| 366 | got := decodeRelocationOutput(t, stdout.Bytes()) |
| 367 | if len(got.Results) != 2 { |
| 368 | t.Fatalf("results = %d, want 2", len(got.Results)) |
| 369 | } |
| 370 | if got.Results[0].Status != relocationJSONStatusSkipped || got.Results[1].Status != relocationJSONStatusMoved { |
| 371 | t.Fatalf("statuses = %q, %q; want skipped, moved", got.Results[0].Status, got.Results[1].Status) |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | func TestMvIfExistsSkipTextModeQuiet(t *testing.T) { |
| 376 | stubFilesClient(t, &mockFilesClient{ |
nothing calls this directly
no test coverage detected