MCPcopy
hub / github.com/rclone/rclone / TestServerSideCopyOverSelf

Function TestServerSideCopyOverSelf

fs/sync/sync_test.go:647–672  ·  view source on GitHub ↗

Test server-side copying a file over itself

(t *testing.T)

Source from the content-addressed store, hash-verified

645
646// Test server-side copying a file over itself
647func TestServerSideCopyOverSelf(t *testing.T) {
648 ctx := context.Background()
649 r := fstest.NewRun(t)
650 file1 := r.WriteObject(ctx, "sub dir/hello world", "hello world", t1)
651 r.CheckRemoteItems(t, file1)
652
653 FremoteCopy, _, finaliseCopy, err := fstest.RandomRemote()
654 require.NoError(t, err)
655 defer finaliseCopy()
656 t.Logf("Server side copy (if possible) %v -> %v", r.Fremote, FremoteCopy)
657
658 ctx = predictDstFromLogger(ctx)
659 err = CopyDir(ctx, FremoteCopy, r.Fremote, false)
660 require.NoError(t, err)
661 testLoggerVsLsf(ctx, FremoteCopy, r.Fremote, operations.GetLoggerOpt(ctx).JSON, t)
662 fstest.CheckItems(t, FremoteCopy, file1)
663
664 file2 := r.WriteObject(ctx, "sub dir/hello world", "hello world again", t2)
665 r.CheckRemoteItems(t, file2)
666
667 ctx = predictDstFromLogger(ctx)
668 err = CopyDir(ctx, FremoteCopy, r.Fremote, false)
669 require.NoError(t, err)
670 testLoggerVsLsf(ctx, FremoteCopy, r.Fremote, operations.GetLoggerOpt(ctx).JSON, t)
671 fstest.CheckItems(t, FremoteCopy, file2)
672}
673
674// Test moving a file over itself
675func TestMoveOverSelf(t *testing.T) {

Callers

nothing calls this directly

Calls 10

WriteObjectMethod · 0.95
CheckRemoteItemsMethod · 0.95
NewRunFunction · 0.92
RandomRemoteFunction · 0.92
GetLoggerOptFunction · 0.92
CheckItemsFunction · 0.92
predictDstFromLoggerFunction · 0.85
testLoggerVsLsfFunction · 0.85
LogfMethod · 0.80
CopyDirFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…