tmpDirEntries counts the files left behind in the cache's .tmp subdir, so tests can assert PutStream never leaks a temp file.
(t *testing.T, c *DiskCache)
| 202 | if _, err := c.PutStream(bad, bytes.NewReader([]byte("x"))); err == nil { |
| 203 | t.Error("PutStream should reject invalid key") |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | // TestDiskCacheEviction exercises LRU eviction when the cache fills up. |
| 208 | // We set maxBytes tiny by construction: NewDiskCache uses statfs * percent, |
| 209 | // so we directly mutate the cache after construction for a predictable test. |
| 210 | func TestDiskCacheEviction(t *testing.T) { |
| 211 | c := newTestCache(t) |
| 212 | // Force the eviction threshold low so we trigger it quickly. |
| 213 | c.maxBytes = 100 |
| 214 |
no test coverage detected