MCPcopy
hub / github.com/rclone/rclone / TestSyncWithTrackRenamesStrategyLeaf

Function TestSyncWithTrackRenamesStrategyLeaf

fs/sync/sync_test.go:1671–1708  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1669}
1670
1671func TestSyncWithTrackRenamesStrategyLeaf(t *testing.T) {
1672 ctx := context.Background()
1673 ctx, ci := fs.AddConfig(ctx)
1674 r := fstest.NewRun(t)
1675
1676 ci.TrackRenames = true
1677 ci.TrackRenamesStrategy = "leaf"
1678
1679 canTrackRenames := operations.CanServerSideMove(r.Fremote) && r.Fremote.Precision() != fs.ModTimeNotSupported
1680 t.Logf("Can track renames: %v", canTrackRenames)
1681
1682 f1 := r.WriteFile("potato", "Potato Content", t1)
1683 f2 := r.WriteFile("sub/yam", "Yam Content", t2)
1684
1685 accounting.GlobalStats().ResetCounters()
1686 ctx = predictDstFromLogger(ctx)
1687 require.NoError(t, Sync(ctx, r.Fremote, r.Flocal, false))
1688 testLoggerVsLsf(ctx, r.Fremote, r.Flocal, operations.GetLoggerOpt(ctx).JSON, t)
1689
1690 r.CheckRemoteItems(t, f1, f2)
1691 r.CheckLocalItems(t, f1, f2)
1692
1693 // Now rename locally.
1694 f2 = r.RenameFile(f2, "yam")
1695
1696 accounting.GlobalStats().ResetCounters()
1697 ctx = predictDstFromLogger(ctx)
1698 require.NoError(t, Sync(ctx, r.Fremote, r.Flocal, false))
1699 testLoggerVsLsf(ctx, r.Fremote, r.Flocal, operations.GetLoggerOpt(ctx).JSON, t)
1700
1701 r.CheckRemoteItems(t, f1, f2)
1702
1703 // Check we renamed something if we should have
1704 if canTrackRenames {
1705 renames := accounting.GlobalStats().Renames(0)
1706 assert.Equal(t, canTrackRenames, renames != 0, fmt.Sprintf("canTrackRenames=%v, renames=%d", canTrackRenames, renames))
1707 }
1708}
1709
1710func toyFileTransfers(r *fstest.Run) int64 {
1711 remote := r.Fremote.Name()

Callers

nothing calls this directly

Calls 15

WriteFileMethod · 0.95
CheckRemoteItemsMethod · 0.95
CheckLocalItemsMethod · 0.95
RenameFileMethod · 0.95
AddConfigFunction · 0.92
NewRunFunction · 0.92
CanServerSideMoveFunction · 0.92
GlobalStatsFunction · 0.92
GetLoggerOptFunction · 0.92
predictDstFromLoggerFunction · 0.85
SyncFunction · 0.85
testLoggerVsLsfFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…