mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 09:41:44 +08:00
vfs: make cache tests more reliable
This commit is contained in:
parent
eb91356e28
commit
f27c2d9760
|
@ -511,9 +511,6 @@ func TestCachePurgeOverQuota(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
err = ioutil.WriteFile(p, []byte("hello2"), 0600)
|
err = ioutil.WriteFile(p, []byte("hello2"), 0600)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
// make it definitely after
|
|
||||||
t1 := time.Now().Add(10 * time.Second)
|
|
||||||
c.updateStat("sub/dir2/potato2", t1, 0)
|
|
||||||
|
|
||||||
assert.Equal(t, []string{
|
assert.Equal(t, []string{
|
||||||
`name="" isFile=false opens=2 size=0`,
|
`name="" isFile=false opens=2 size=0`,
|
||||||
|
@ -547,6 +544,10 @@ func TestCachePurgeOverQuota(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, int64(11), c.used)
|
assert.Equal(t, int64(11), c.used)
|
||||||
|
|
||||||
|
// make potato2 definitely after potato
|
||||||
|
t1 := time.Now().Add(10 * time.Second)
|
||||||
|
c.updateStat("sub/dir2/potato2", t1, 6)
|
||||||
|
|
||||||
// Check only potato removed to get below quota
|
// Check only potato removed to get below quota
|
||||||
removed = nil
|
removed = nil
|
||||||
c._purgeOverQuota(10, remove)
|
c._purgeOverQuota(10, remove)
|
||||||
|
@ -570,9 +571,6 @@ func TestCachePurgeOverQuota(t *testing.T) {
|
||||||
err = ioutil.WriteFile(p, []byte("hello"), 0600)
|
err = ioutil.WriteFile(p, []byte("hello"), 0600)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
c.close("sub/dir/potato")
|
c.close("sub/dir/potato")
|
||||||
// make it definitely after
|
|
||||||
t2 := t1.Add(20 * time.Second)
|
|
||||||
c.updateStat("sub/dir/potato", t2, 5)
|
|
||||||
|
|
||||||
// Update the stats to read the total size
|
// Update the stats to read the total size
|
||||||
err = c.updateStats()
|
err = c.updateStats()
|
||||||
|
@ -588,6 +586,10 @@ func TestCachePurgeOverQuota(t *testing.T) {
|
||||||
`name="sub/dir2/potato2" isFile=true opens=0 size=6`,
|
`name="sub/dir2/potato2" isFile=true opens=0 size=6`,
|
||||||
}, itemAsString(c))
|
}, itemAsString(c))
|
||||||
|
|
||||||
|
// make potato definitely after potato2
|
||||||
|
t2 := t1.Add(20 * time.Second)
|
||||||
|
c.updateStat("sub/dir/potato", t2, 5)
|
||||||
|
|
||||||
// Check only potato2 removed to get below quota
|
// Check only potato2 removed to get below quota
|
||||||
removed = nil
|
removed = nil
|
||||||
c._purgeOverQuota(10, remove)
|
c._purgeOverQuota(10, remove)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user