(t *testing.T)
| 353 | } |
| 354 | |
| 355 | func TestCpIfExistsSkipExistingDestinationDoesNotCopy(t *testing.T) { |
| 356 | var copied bool |
| 357 | stubFilesClient(t, &mockFilesClient{ |
| 358 | getMetadataFn: func(arg *files.GetMetadataArg) (files.IsMetadata, error) { |
| 359 | if arg.Path != "/dest/file.txt" { |
| 360 | t.Fatalf("metadata path = %q, want /dest/file.txt", arg.Path) |
| 361 | } |
| 362 | return relocationTestFileMetadata(arg.Path, 8), nil |
| 363 | }, |
| 364 | copyV2Fn: func(arg *files.RelocationArg) (*files.RelocationResult, error) { |
| 365 | copied = true |
| 366 | return nil, nil |
| 367 | }, |
| 368 | }) |
| 369 | |
| 370 | var stdout bytes.Buffer |
| 371 | cmd := newRelocationTestCommand(&stdout, nil) |
| 372 | if err := cmd.Flags().Set("if-exists", relocationIfExistsSkip); err != nil { |
| 373 | t.Fatal(err) |
| 374 | } |
| 375 | |
| 376 | if err := cp(cmd, []string{"/src/file.txt", "/dest/file.txt"}); err != nil { |
| 377 | t.Fatalf("cp error: %v", err) |
| 378 | } |
| 379 | if copied { |
| 380 | t.Fatal("CopyV2 called for skipped destination") |
| 381 | } |
| 382 | got := decodeRelocationOutput(t, stdout.Bytes()) |
| 383 | if len(got.Results) != 1 { |
| 384 | t.Fatalf("results = %d, want 1", len(got.Results)) |
| 385 | } |
| 386 | if got.Results[0].Status != relocationJSONStatusSkipped { |
| 387 | t.Fatalf("status = %q, want skipped", got.Results[0].Status) |
| 388 | } |
| 389 | if got.Results[0].Input.FromPath != "/src/file.txt" || got.Results[0].Input.ToPath != "/dest/file.txt" { |
| 390 | t.Fatalf("input = %#v, want source and destination", got.Results[0].Input) |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | func TestCpIfExistsSkipMissingDestinationCopies(t *testing.T) { |
| 395 | var copied []*files.RelocationArg |
nothing calls this directly
no test coverage detected