Cache cap test: exercise the REAL _run_maintenance_write, not a stub

Self-review caught a test-fidelity hole: the temp cache overrode
_run_maintenance_write with a simplified version, so evict_over_capacity was
tested against the stub's plumbing, not production's (retry + connection
handling). Removed the override — _get_db is now the only injected seam, so the
test runs the genuine code path. Differential-verified the LRU assertions are
real: flipping ORDER BY ASC->DESC makes them fail. 8/8 pass; ruff clean.
This commit is contained in:
BoulderBadgeDad 2026-05-30 23:31:35 -07:00
parent bb2241498f
commit 3b5a5518a6

View file

@ -115,14 +115,9 @@ class _TempCache(MetadataCache):
return _NonClosingConn(outer._conn)
return _DB()
# evict_over_capacity uses self._run_maintenance_write -> _get_db; the base
# _run_maintenance_write just calls the operation. Add a tiny passthrough
# if the base needs it (it does in the real class).
def _run_maintenance_write(self, label, operation, default=0):
try:
return operation(self._get_db()._get_connection())
except Exception:
return default
# NOTE: we deliberately do NOT override _run_maintenance_write — the test
# exercises the REAL method (retry + connection handling) so we're testing
# production code, not a stub. _get_db is the only injected seam.
def _add_rows(cache, specs):