mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 16:34:30 +01:00
fs/cache: add Entries() for finding how many entries in the fscache #4811
This commit is contained in:
parent
ebd9462ea6
commit
feaaca4987
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() {
|
||||
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())
|
||||
}
|
||||
|
||||
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 New Issue
Block a user