fix: preserve empty Grok hook groups

This commit is contained in:
ZacharyZhang-NY committed 2026-07-19 08:01:44 -04:00
1 parent 407c396c17
commit bdcbc36002
2 files changed
+13 -5

No files matched your search

+7 -3
View File
@@ -341,7 +341,7 @@ def test_install_replaces_stale_handlers_for_every_agent(
assert len(current["hooks"]["PostToolUse"]) == 1
def test_uninstall_preserves_untouched_empty_native_event(
def test_uninstall_preserves_untouched_empty_native_group(
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
) -> None:
fixture = prepare_fixture(
@@ -349,13 +349,17 @@ def test_uninstall_preserves_untouched_empty_native_event(
)
fixture.plugin.install(fixture.config)
settings = json.loads(fixture.config_path.read_text(encoding="utf-8"))
settings["hooks"]["PreToolUse"] = []
settings["hooks"]["PreToolUse"].insert(
0, {"hooks": [], "label": "keep empty group"}
)
fixture.config_path.write_text(json.dumps(settings), encoding="utf-8")
fixture.plugin.uninstall(AGENT_ID)
remaining = json.loads(fixture.config_path.read_text(encoding="utf-8"))
assert remaining["hooks"]["PreToolUse"] == []
assert remaining["hooks"]["PreToolUse"] == [
{"hooks": [], "label": "keep empty group"}
]
assert "PostToolUse" not in remaining["hooks"]