MCPcopy Index your code
hub / github.com/rclone/rclone / TestSyncBasedOnCheckSum

Function TestSyncBasedOnCheckSum

fs/sync/sync_test.go:772–805  ·  view source on GitHub ↗

Create a file and sync it. Change the last modified date and resync. If we're only doing sync by size and checksum, we expect nothing to to be transferred on the second sync.

(t *testing.T)

Source from the content-addressed store, hash-verified

770// If we're only doing sync by size and checksum, we expect nothing to
771// to be transferred on the second sync.
772func TestSyncBasedOnCheckSum(t *testing.T) {
773 ctx := context.Background()
774 ctx, ci := fs.AddConfig(ctx)
775 r := fstest.NewRun(t)
776 ci.CheckSum = true
777
778 file1 := r.WriteFile("check sum", "-", t1)
779 r.CheckLocalItems(t, file1)
780
781 accounting.GlobalStats().ResetCounters()
782 ctx = predictDstFromLogger(ctx)
783 err := Sync(ctx, r.Fremote, r.Flocal, false)
784 require.NoError(t, err)
785 testLoggerVsLsf(ctx, r.Fremote, r.Flocal, operations.GetLoggerOpt(ctx).JSON, t)
786
787 // We should have transferred exactly one file.
788 assert.Equal(t, toyFileTransfers(r), accounting.GlobalStats().GetTransfers())
789 r.CheckRemoteItems(t, file1)
790
791 // Change last modified date only
792 file2 := r.WriteFile("check sum", "-", t2)
793 r.CheckLocalItems(t, file2)
794
795 accounting.GlobalStats().ResetCounters()
796 ctx = predictDstFromLogger(ctx)
797 err = Sync(ctx, r.Fremote, r.Flocal, false)
798 require.NoError(t, err)
799 testLoggerVsLsf(ctx, r.Fremote, r.Flocal, operations.GetLoggerOpt(ctx).JSON, t)
800
801 // We should have transferred no files
802 assert.Equal(t, int64(0), accounting.GlobalStats().GetTransfers())
803 r.CheckLocalItems(t, file2)
804 r.CheckRemoteItems(t, file1)
805}
806
807// Create a file and sync it. Change the last modified date and the
808// file contents but not the size. If we're only doing sync by size

Callers

nothing calls this directly

Calls 14

WriteFileMethod · 0.95
CheckLocalItemsMethod · 0.95
CheckRemoteItemsMethod · 0.95
AddConfigFunction · 0.92
NewRunFunction · 0.92
GlobalStatsFunction · 0.92
GetLoggerOptFunction · 0.92
predictDstFromLoggerFunction · 0.85
SyncFunction · 0.85
testLoggerVsLsfFunction · 0.85
toyFileTransfersFunction · 0.85
ResetCountersMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…