Skip to content

Commit 72c06d8

Browse files
marcelsafinCopilot
andcommitted
test: cover the OSError half of the unreadable-template boundary
Review follow-up: add a mocked PermissionError case so both promised exception paths are protected under privileged CI. Assisted-by: GitHub Copilot (model: claude-fable-5, autonomous) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent bb836bd commit 72c06d8

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

tests/integrations/test_events.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,31 @@ def test_unreadable_template_returns_none(self, tmp_path):
12871287
argv = _resolve_event_command_argv(cmd_dir / "boot.md", tmp_path, None)
12881288
assert argv is None
12891289

1290+
def test_permission_denied_template_returns_none(self, tmp_path, monkeypatch):
1291+
"""The same boundary must cover ``OSError`` (e.g. permission denied).
1292+
1293+
Mocked rather than chmod-based so the case also holds under
1294+
privileged CI where permission bits are not enforced.
1295+
"""
1296+
from specify_cli.events import _resolve_event_command_argv
1297+
1298+
cmd_dir = tmp_path / ".specify" / "templates" / "commands"
1299+
cmd_dir.mkdir(parents=True)
1300+
template = cmd_dir / "boot.md"
1301+
template.write_text("---\ndescription: Boot\n---\nBody\n")
1302+
1303+
original_read_text = Path.read_text
1304+
1305+
def failing_read_text(self_path, *args, **kwargs):
1306+
if self_path == template:
1307+
raise PermissionError(13, "Permission denied")
1308+
return original_read_text(self_path, *args, **kwargs)
1309+
1310+
monkeypatch.setattr(Path, "read_text", failing_read_text)
1311+
1312+
argv = _resolve_event_command_argv(template, tmp_path, None)
1313+
assert argv is None
1314+
12901315
def test_ps_variant_prefixed_with_powershell_launcher(self, tmp_path):
12911316
"""S6: the ps variant prefixes argv with pwsh/powershell -File so
12921317
subprocess.run(shell=False) can execute the .ps1 script."""

0 commit comments

Comments
 (0)