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

Function TestSyncOverlapWithFilter

fs/sync/sync_test.go:1999–2095  ·  view source on GitHub ↗

Test a sync with filtered overlap

(t *testing.T)

Source from the content-addressed store, hash-verified

1997
1998// Test a sync with filtered overlap
1999func TestSyncOverlapWithFilter(t *testing.T) {
2000 ctx := context.Background()
2001 r := fstest.NewRun(t)
2002
2003 fi, err := filter.NewFilter(nil)
2004 require.NoError(t, err)
2005 require.NoError(t, fi.Add(false, "/rclone-sync-test/"))
2006 require.NoError(t, fi.Add(false, "*/layer2/"))
2007 fi.Opt.ExcludeFile = []string{".ignore"}
2008 filterCtx := filter.ReplaceConfig(ctx, fi)
2009
2010 subRemoteName := r.FremoteName + "/rclone-sync-test"
2011 FremoteSync, err := fs.NewFs(ctx, subRemoteName)
2012 require.NoError(t, FremoteSync.Mkdir(ctx, ""))
2013 require.NoError(t, err)
2014
2015 subRemoteName2 := r.FremoteName + "/rclone-sync-test-include/layer2"
2016 FremoteSync2, err := fs.NewFs(ctx, subRemoteName2)
2017 require.NoError(t, FremoteSync2.Mkdir(ctx, ""))
2018 require.NoError(t, err)
2019
2020 subRemoteName3 := r.FremoteName + "/rclone-sync-test-ignore-file"
2021 FremoteSync3, err := fs.NewFs(ctx, subRemoteName3)
2022 require.NoError(t, FremoteSync3.Mkdir(ctx, ""))
2023 require.NoError(t, err)
2024 r.WriteObject(context.Background(), "rclone-sync-test-ignore-file/.ignore", "-", t1)
2025
2026 checkErr := func(err error) {
2027 require.Error(t, err)
2028 assert.True(t, fserrors.IsFatalError(err))
2029 assert.Equal(t, fs.ErrorOverlapping.Error(), err.Error())
2030 accounting.GlobalStats().ResetCounters()
2031 }
2032
2033 checkNoErr := func(err error) {
2034 require.NoError(t, err)
2035 }
2036
2037 accounting.GlobalStats().ResetCounters()
2038 filterCtx = predictDstFromLogger(filterCtx)
2039 checkNoErr(Sync(filterCtx, FremoteSync, r.Fremote, false))
2040 checkErr(Sync(ctx, FremoteSync, r.Fremote, false))
2041 checkNoErr(Sync(filterCtx, r.Fremote, FremoteSync, false))
2042 testLoggerVsLsf(filterCtx, r.Fremote, r.Flocal, operations.GetLoggerOpt(filterCtx).JSON, t)
2043 filterCtx = predictDstFromLogger(filterCtx)
2044 checkErr(Sync(ctx, r.Fremote, FremoteSync, false))
2045 testLoggerVsLsf(filterCtx, r.Fremote, r.Flocal, operations.GetLoggerOpt(filterCtx).JSON, t)
2046 filterCtx = predictDstFromLogger(filterCtx)
2047 checkErr(Sync(filterCtx, r.Fremote, r.Fremote, false))
2048 testLoggerVsLsf(filterCtx, r.Fremote, r.Flocal, operations.GetLoggerOpt(filterCtx).JSON, t)
2049 filterCtx = predictDstFromLogger(filterCtx)
2050 checkErr(Sync(ctx, r.Fremote, r.Fremote, false))
2051 testLoggerVsLsf(filterCtx, r.Fremote, r.Flocal, operations.GetLoggerOpt(filterCtx).JSON, t)
2052 filterCtx = predictDstFromLogger(filterCtx)
2053 checkErr(Sync(filterCtx, FremoteSync, FremoteSync, false))
2054 testLoggerVsLsf(filterCtx, r.Fremote, r.Flocal, operations.GetLoggerOpt(filterCtx).JSON, t)
2055 filterCtx = predictDstFromLogger(filterCtx)
2056 checkErr(Sync(ctx, FremoteSync, FremoteSync, false))

Callers

nothing calls this directly

Calls 15

AddMethod · 0.95
MkdirMethod · 0.95
WriteObjectMethod · 0.95
NewRunFunction · 0.92
NewFilterFunction · 0.92
ReplaceConfigFunction · 0.92
NewFsFunction · 0.92
IsFatalErrorFunction · 0.92
GlobalStatsFunction · 0.92
GetLoggerOptFunction · 0.92
predictDstFromLoggerFunction · 0.85
SyncFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…