MCPcopy
hub / github.com/rclone/rclone / testServerSideMove

Function testServerSideMove

fs/sync/sync_test.go:1720–1790  ·  view source on GitHub ↗

Test a server-side move if possible, or the backup path if not

(ctx context.Context, t *testing.T, r *fstest.Run, withFilter, testDeleteEmptyDirs bool)

Source from the content-addressed store, hash-verified

1718
1719// Test a server-side move if possible, or the backup path if not
1720func testServerSideMove(ctx context.Context, t *testing.T, r *fstest.Run, withFilter, testDeleteEmptyDirs bool) {
1721 FremoteMove, _, finaliseMove, err := fstest.RandomRemote()
1722 require.NoError(t, err)
1723 defer finaliseMove()
1724
1725 file1 := r.WriteBoth(ctx, "potato2", "------------------------------------------------------------", t1)
1726 file2 := r.WriteBoth(ctx, "empty space", "-", t2)
1727 file3u := r.WriteBoth(ctx, "potato3", "------------------------------------------------------------ UPDATED", t2)
1728
1729 if testDeleteEmptyDirs {
1730 err := operations.Mkdir(ctx, r.Fremote, "tomatoDir")
1731 require.NoError(t, err)
1732 }
1733
1734 r.CheckRemoteItems(t, file2, file1, file3u)
1735
1736 t.Logf("Server side move (if possible) %v -> %v", r.Fremote, FremoteMove)
1737
1738 // Write just one file in the new remote
1739 r.WriteObjectTo(ctx, FremoteMove, "empty space", "-", t2, false)
1740 file3 := r.WriteObjectTo(ctx, FremoteMove, "potato3", "------------------------------------------------------------", t1, false)
1741 fstest.CheckItems(t, FremoteMove, file2, file3)
1742
1743 // Do server-side move
1744 accounting.GlobalStats().ResetCounters()
1745 // ctx = predictDstFromLogger(ctx) // not currently supported -- doesn't list all contents of dir.
1746 err = MoveDir(ctx, FremoteMove, r.Fremote, testDeleteEmptyDirs, false)
1747 require.NoError(t, err)
1748 // testLoggerVsLsf(ctx, r.Fremote, r.Flocal, operations.GetLoggerOpt(ctx).JSON, t)
1749
1750 if withFilter {
1751 r.CheckRemoteItems(t, file2)
1752 } else {
1753 r.CheckRemoteItems(t)
1754 }
1755
1756 if testDeleteEmptyDirs {
1757 r.CheckRemoteListing(t, nil, []string{})
1758 }
1759
1760 fstest.CheckItems(t, FremoteMove, file2, file1, file3u)
1761
1762 // Create a new empty remote for stuff to be moved into
1763 FremoteMove2, _, finaliseMove2, err := fstest.RandomRemote()
1764 require.NoError(t, err)
1765 defer finaliseMove2()
1766
1767 if testDeleteEmptyDirs {
1768 err := operations.Mkdir(ctx, FremoteMove, "tomatoDir")
1769 require.NoError(t, err)
1770 }
1771
1772 // Move it back to a new empty remote, dst does not exist this time
1773 accounting.GlobalStats().ResetCounters()
1774 // ctx = predictDstFromLogger(ctx)
1775 err = MoveDir(ctx, FremoteMove2, FremoteMove, testDeleteEmptyDirs, false)
1776 require.NoError(t, err)
1777 // testLoggerVsLsf(ctx, r.Fremote, r.Flocal, operations.GetLoggerOpt(ctx).JSON, t)

Callers 3

TestServerSideMoveFunction · 0.85

Calls 13

RandomRemoteFunction · 0.92
MkdirFunction · 0.92
CheckItemsFunction · 0.92
GlobalStatsFunction · 0.92
GetModifyWindowFunction · 0.92
MoveDirFunction · 0.85
WriteBothMethod · 0.80
CheckRemoteItemsMethod · 0.80
LogfMethod · 0.80
WriteObjectToMethod · 0.80
ResetCountersMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…