MCPcopy
hub / github.com/rclone/rclone / TestServerSideMoveOverSelf

Function TestServerSideMoveOverSelf

fs/sync/sync_test.go:692–730  ·  view source on GitHub ↗

Test server-side moving a file over itself

(t *testing.T)

Source from the content-addressed store, hash-verified

690
691// Test server-side moving a file over itself
692func TestServerSideMoveOverSelf(t *testing.T) {
693 ctx := context.Background()
694 r := fstest.NewRun(t)
695 file1 := r.WriteObject(ctx, "sub dir/hello world", "hello world", t1)
696 r.CheckRemoteItems(t, file1)
697
698 FremoteCopy, _, finaliseCopy, err := fstest.RandomRemote()
699 require.NoError(t, err)
700 defer finaliseCopy()
701 t.Logf("Server side copy (if possible) %v -> %v", r.Fremote, FremoteCopy)
702
703 ctx = predictDstFromLogger(ctx)
704 err = CopyDir(ctx, FremoteCopy, r.Fremote, false)
705 require.NoError(t, err)
706 testLoggerVsLsf(ctx, FremoteCopy, r.Fremote, operations.GetLoggerOpt(ctx).JSON, t)
707 fstest.CheckItems(t, FremoteCopy, file1)
708
709 file2 := r.WriteObject(ctx, "sub dir/hello world", "hello world again", t2)
710 r.CheckRemoteItems(t, file2)
711
712 // ctx = predictDstFromLogger(ctx)
713 err = MoveDir(ctx, FremoteCopy, r.Fremote, false, false)
714 require.NoError(t, err)
715 // testLoggerVsLsf(ctx, r.Fremote, r.Flocal, operations.GetLoggerOpt(ctx).JSON, t) // not currently supported
716 r.CheckRemoteItems(t)
717 fstest.CheckItems(t, FremoteCopy, file2)
718
719 // check that individual file moves also work without MoveDir
720 file3 := r.WriteObject(ctx, "sub dir/hello world", "hello world a third time", t3)
721 r.CheckRemoteItems(t, file3)
722
723 ctx = predictDstFromLogger(ctx)
724 fs.Debugf(nil, "testing file moves")
725 err = moveDir(ctx, FremoteCopy, r.Fremote, false, false)
726 require.NoError(t, err)
727 testLoggerVsLsf(ctx, FremoteCopy, r.Fremote, operations.GetLoggerOpt(ctx).JSON, t)
728 r.CheckRemoteItems(t)
729 fstest.CheckItems(t, FremoteCopy, file3)
730}
731
732// Check that if the local file doesn't exist when we copy it up,
733// nothing happens to the remote file

Callers

nothing calls this directly

Calls 13

WriteObjectMethod · 0.95
CheckRemoteItemsMethod · 0.95
NewRunFunction · 0.92
RandomRemoteFunction · 0.92
GetLoggerOptFunction · 0.92
CheckItemsFunction · 0.92
DebugfFunction · 0.92
predictDstFromLoggerFunction · 0.85
testLoggerVsLsfFunction · 0.85
MoveDirFunction · 0.85
moveDirFunction · 0.85
LogfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…