mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-17 09:41:58 +00:00
test: assert disk cleanup prunes protected walks
This commit is contained in:
parent
40699c3292
commit
a688d2a1bd
1 changed files with 12 additions and 1 deletions
|
|
@ -352,13 +352,24 @@ class TestTrackForgetQuick:
|
|||
for d in ("logs", "memories", "sessions", "cron", "cache"):
|
||||
assert (_isolate_env / d).exists(), f"{d}/ should be preserved"
|
||||
|
||||
def test_quick_does_not_descend_into_protected_top_level_dirs(self, _isolate_env):
|
||||
def test_quick_does_not_descend_into_protected_top_level_dirs(
|
||||
self, _isolate_env, monkeypatch
|
||||
):
|
||||
dg = _load_lib()
|
||||
protected_empty = (
|
||||
_isolate_env / "hermes-agent" / "node_modules" / "pkg" / "empty"
|
||||
)
|
||||
protected_empty.mkdir(parents=True)
|
||||
|
||||
original_iterdir = Path.iterdir
|
||||
|
||||
def guarded_iterdir(path):
|
||||
if path == _isolate_env / "hermes-agent":
|
||||
raise AssertionError("quick() descended into protected hermes-agent/")
|
||||
return original_iterdir(path)
|
||||
|
||||
monkeypatch.setattr(Path, "iterdir", guarded_iterdir)
|
||||
|
||||
dg.quick()
|
||||
|
||||
assert protected_empty.exists()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue