Test that the default cache_max_bytes counts what the cache holds

With a fake free-space probe, an empty cache with 4 GiB free gets a
3 GiB default, and the same cache once it holds those 3 GiB, with
1 GiB left free, must keep 3 GiB. The default is still 75% of the
free space alone, so the second check fails: this is the bug in
#184. computeDefaultMaxBytes
only calls the config's existing computation so the test compiles.

Model: opus-5-5
This commit is contained in:
2026-10-04 16:25:17 +00:00
parent 48f21d4ecf
commit 35e771e2b6
2 changed files with 69 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
package imgcache
import (
"context"
"path/filepath"
"sneak.berlin/go/pixa/internal/config"
)
// computeDefaultMaxBytes returns the default cache size limit for an
// omitted cache_max_bytes, for the filesystem holding <state_dir>/cache/.
func (c *Cache) computeDefaultMaxBytes(
_ context.Context, probe config.FreeSpaceProbeFunc,
) (int64, error) {
return config.ComputeDefaultCacheMaxBytes(
filepath.Join(c.config.StateDir, "cache"), probe)
}