From 3b5a5518a61155aed2fc89ae7e6d69e29cca6589 Mon Sep 17 00:00:00 2001 From: BoulderBadgeDad Date: Sat, 30 May 2026 23:31:35 -0700 Subject: [PATCH] Cache cap test: exercise the REAL _run_maintenance_write, not a stub MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- tests/metadata/test_cache_capacity_eviction.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/metadata/test_cache_capacity_eviction.py b/tests/metadata/test_cache_capacity_eviction.py index e4937b2e..ff0a6d58 100644 --- a/tests/metadata/test_cache_capacity_eviction.py +++ b/tests/metadata/test_cache_capacity_eviction.py @@ -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):