Fix pruning on DiskCache object creation

This commit is contained in:
Kovid Goyal 2025-09-30 13:18:00 +05:30
parent 8fdbf8d7da
commit 712faa7aa5
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 26 additions and 11 deletions

View file

@ -69,4 +69,10 @@ func TestDiskCache(t *testing.T) {
ak("k1", "k2")
dc.Add("k3", map[string][]byte{"1": []byte(strings.Repeat("a", int(dc.MaxSize)-10))})
ak("k3", "k2")
// check that creating a new disk cache prunes
_, err = NewDiskCache(tdir, dc.MaxSize-8)
if err != nil {
t.Fatal(err)
}
ak("k3")
}