From d469002be7a0eaf1b47776c2f4799a933ba2d3a5 Mon Sep 17 00:00:00 2001 From: agentson Date: Mon, 2 Mar 2026 01:33:39 +0900 Subject: [PATCH] test: add unhappy-path coverage for newline guard tokens --- tests/test_validate_governance_assets.py | 43 ++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/test_validate_governance_assets.py b/tests/test_validate_governance_assets.py index 5bb023e..f5a425d 100644 --- a/tests/test_validate_governance_assets.py +++ b/tests/test_validate_governance_assets.py @@ -215,6 +215,27 @@ def test_must_contain_enforces_workflow_newline_helper_tokens(tmp_path) -> None: assert errors == [] +def test_must_contain_fails_when_workflow_missing_newline_helper_token(tmp_path) -> None: + module = _load_module() + workflow_doc = tmp_path / "workflow.md" + workflow_doc.write_text( + "\n".join( + [ + "Session Handover Gate (Mandatory)", + "python3 scripts/session_handover_check.py --strict", + ] + ), + encoding="utf-8", + ) + errors: list[str] = [] + module.must_contain( + workflow_doc, + ["scripts/tea_comment.sh"], + errors, + ) + assert any("scripts/tea_comment.sh" in err for err in errors) + + def test_must_contain_enforces_commands_newline_section_tokens(tmp_path) -> None: module = _load_module() commands_doc = tmp_path / "commands.md" @@ -241,3 +262,25 @@ def test_must_contain_enforces_commands_newline_section_tokens(tmp_path) -> None errors, ) assert errors == [] + + +def test_must_contain_fails_when_commands_missing_newline_section_token(tmp_path) -> None: + module = _load_module() + commands_doc = tmp_path / "commands.md" + commands_doc.write_text( + "\n".join( + [ + "Session Handover Preflight (Mandatory)", + "python3 scripts/session_handover_check.py --strict", + "scripts/tea_comment.sh", + ] + ), + encoding="utf-8", + ) + errors: list[str] = [] + module.must_contain( + commands_doc, + ["Comment Newline Escaping"], + errors, + ) + assert any("Comment Newline Escaping" in err for err in errors)