(t *testing.T)
| 233 | } |
| 234 | |
| 235 | func TestMvIfExistsSkipExistingDestinationDoesNotMove(t *testing.T) { |
| 236 | var moved bool |
| 237 | stubFilesClient(t, &mockFilesClient{ |
| 238 | getMetadataFn: func(arg *files.GetMetadataArg) (files.IsMetadata, error) { |
| 239 | if arg.Path != "/dest/file.txt" { |
| 240 | t.Fatalf("metadata path = %q, want /dest/file.txt", arg.Path) |
| 241 | } |
| 242 | return relocationTestFileMetadata(arg.Path, 8), nil |
| 243 | }, |
| 244 | moveV2Fn: func(arg *files.RelocationArg) (*files.RelocationResult, error) { |
| 245 | moved = true |
| 246 | return nil, nil |
| 247 | }, |
| 248 | }) |
| 249 | |
| 250 | var stdout bytes.Buffer |
| 251 | cmd := newRelocationTestCommand(&stdout, nil) |
| 252 | if err := cmd.Flags().Set("if-exists", relocationIfExistsSkip); err != nil { |
| 253 | t.Fatal(err) |
| 254 | } |
| 255 | |
| 256 | if err := mv(cmd, []string{"/src/file.txt", "/dest/file.txt"}); err != nil { |
| 257 | t.Fatalf("mv error: %v", err) |
| 258 | } |
| 259 | if moved { |
| 260 | t.Fatal("MoveV2 called for skipped destination") |
| 261 | } |
| 262 | got := decodeRelocationOutput(t, stdout.Bytes()) |
| 263 | if len(got.Results) != 1 { |
| 264 | t.Fatalf("results = %d, want 1", len(got.Results)) |
| 265 | } |
| 266 | if got.Results[0].Status != relocationJSONStatusSkipped { |
| 267 | t.Fatalf("status = %q, want skipped", got.Results[0].Status) |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | func TestMvIfExistsSkipMissingDestinationMoves(t *testing.T) { |
| 272 | var moved []*files.RelocationArg |
nothing calls this directly
no test coverage detected