From a688d2a1bd2941c39a7c9efd4d97fda399735266 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Mon, 15 Jun 2026 05:07:49 -0700 Subject: [PATCH] test: assert disk cleanup prunes protected walks --- tests/plugins/test_disk_cleanup_plugin.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/plugins/test_disk_cleanup_plugin.py b/tests/plugins/test_disk_cleanup_plugin.py index 38fffd5fbf9..52afddc9c46 100644 --- a/tests/plugins/test_disk_cleanup_plugin.py +++ b/tests/plugins/test_disk_cleanup_plugin.py @@ -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()