forked from TrueCloudLab/rclone
fs/cache: add Entries() for finding how many entries in the fscache #4811
This commit is contained in:
parent
ebd9462ea6
commit
feaaca4987
2 changed files with 18 additions and 0 deletions
5
fs/cache/cache.go
vendored
5
fs/cache/cache.go
vendored
|
@ -128,3 +128,8 @@ func Put(fsString string, f fs.Fs) {
|
||||||
func Clear() {
|
func Clear() {
|
||||||
c.Clear()
|
c.Clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Entries returns the number of entries in the cache
|
||||||
|
func Entries() int {
|
||||||
|
return c.Entries()
|
||||||
|
}
|
||||||
|
|
13
fs/cache/cache_test.go
vendored
13
fs/cache/cache_test.go
vendored
|
@ -180,3 +180,16 @@ func TestClear(t *testing.T) {
|
||||||
|
|
||||||
assert.Equal(t, 0, c.Entries())
|
assert.Equal(t, 0, c.Entries())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEntries(t *testing.T) {
|
||||||
|
cleanup, create := mockNewFs(t)
|
||||||
|
defer cleanup()
|
||||||
|
|
||||||
|
assert.Equal(t, 0, Entries())
|
||||||
|
|
||||||
|
// Create something
|
||||||
|
_, err := GetFn(context.Background(), "mock:/", create)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
assert.Equal(t, 1, Entries())
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue