Skip to content

Commit b283ecb

Browse files
committed
test(compact): isolate manifest sidecar between TestBuildManifest tests
Item 26's Manifest Delta sidecar persists between build_manifest calls. TestBuildManifest tests share a fixed session_id, so without isolation the second call sees a matching fingerprint and renders the 'unchanged' stub instead of the fresh manifest the assertions expect. Add an autouse fixture that clears manifest_sha_* sentinels at the start of each test.
1 parent 893f416 commit b283ecb

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎tests/test_coverage_iter255.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from pathlib import Path
66
from unittest.mock import patch
77

8+
import pytest
9+
810
from token_goat import compact as compact_mod
911
from token_goat import config as config_mod
1012
from token_goat.hooks_common import get_session_context, sanitize_log_str, sanitize_opt
@@ -292,6 +294,23 @@ def _make_session(session_id: str = "testsession123") -> SessionCache:
292294

293295

294296
class TestBuildManifest:
297+
@pytest.fixture(autouse=True)
298+
def _clear_manifest_sentinel(self, tmp_data_dir):
299+
"""Item 26 introduced a Manifest Delta sidecar that persists between
300+
build_manifest calls. Tests in this class share a fixed session_id, so
301+
without isolation the second call sees a matching fingerprint and
302+
renders the "unchanged" stub instead of a fresh manifest. The
303+
tmp_data_dir fixture already scopes paths to a per-test temp dir; this
304+
autouse just guarantees the sentinel slate is clean at entry.
305+
"""
306+
from token_goat import paths as _p # noqa: PLC0415
307+
308+
sentinels = _p.data_dir() / "sentinels"
309+
if sentinels.exists():
310+
for sidecar in sentinels.glob("manifest_sha_*"):
311+
sidecar.unlink(missing_ok=True)
312+
yield
313+
295314
def test_invalid_session_returns_empty(self):
296315
result = compact_mod.build_manifest("../traversal")
297316
assert result == ""

0 commit comments

Comments
 (0)