MCPcopy
hub / github.com/rclone/rclone / TestInternalBug2117

Function TestInternalBug2117

backend/cache/cache_internal_test.go:744–792  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

742}
743
744func TestInternalBug2117(t *testing.T) {
745 vfscommon.Opt.DirCacheTime = fs.Duration(time.Second * 10)
746
747 id := fmt.Sprintf("tib2117%v", time.Now().Unix())
748 rootFs, _ := runInstance.newCacheFs(t, remoteName, id, false, true, map[string]string{"info_age": "72h", "chunk_clean_interval": "15m"})
749
750 if runInstance.rootIsCrypt {
751 t.Skipf("skipping crypt")
752 }
753
754 cfs, err := runInstance.getCacheFs(rootFs)
755 require.NoError(t, err)
756
757 err = cfs.UnWrap().Mkdir(context.Background(), "test")
758 require.NoError(t, err)
759 for i := 1; i <= 4; i++ {
760 err = cfs.UnWrap().Mkdir(context.Background(), fmt.Sprintf("test/dir%d", i))
761 require.NoError(t, err)
762
763 for j := 1; j <= 4; j++ {
764 err = cfs.UnWrap().Mkdir(context.Background(), fmt.Sprintf("test/dir%d/dir%d", i, j))
765 require.NoError(t, err)
766
767 runInstance.writeObjectString(t, cfs.UnWrap(), fmt.Sprintf("test/dir%d/dir%d/test.txt", i, j), "test")
768 }
769 }
770
771 di, err := runInstance.list(t, rootFs, "test/dir1/dir2")
772 require.NoError(t, err)
773 fs.Logf(nil, "len: %v", len(di))
774 require.Len(t, di, 1)
775
776 time.Sleep(time.Second * 30)
777
778 di, err = runInstance.list(t, rootFs, "test/dir1/dir2")
779 require.NoError(t, err)
780 fs.Logf(nil, "len: %v", len(di))
781 require.Len(t, di, 1)
782
783 di, err = runInstance.list(t, rootFs, "test/dir1")
784 require.NoError(t, err)
785 fs.Logf(nil, "len: %v", len(di))
786 require.Len(t, di, 4)
787
788 di, err = runInstance.list(t, rootFs, "test")
789 require.NoError(t, err)
790 fs.Logf(nil, "len: %v", len(di))
791 require.Len(t, di, 4)
792}
793
794// run holds the remotes for a test run
795type run struct {

Callers

nothing calls this directly

Calls 9

DurationTypeAlias · 0.92
LogfFunction · 0.92
newCacheFsMethod · 0.80
getCacheFsMethod · 0.80
writeObjectStringMethod · 0.80
MkdirMethod · 0.65
UnWrapMethod · 0.65
listMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…