From 77143ac6daa3da05c9e8e923e26554740ea4de9d Mon Sep 17 00:00:00 2001 From: opencode-agent Date: Thu, 6 Aug 2026 14:45:18 +0000 Subject: [PATCH] test(project-status): skip exec_real when gh CLI unavailable --- tests/test_project_status_tool.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_project_status_tool.py b/tests/test_project_status_tool.py index 0c7401a..1a7cb8d 100644 --- a/tests/test_project_status_tool.py +++ b/tests/test_project_status_tool.py @@ -30,6 +30,25 @@ from pathlib import Path import pytest + +def _gh_available() -> bool: + """True if `gh auth status` succeeds (local dev machine, not CI runner).""" + try: + return ( + subprocess.run( + ["gh", "auth", "status"], + capture_output=True, + check=False, + ).returncode + == 0 + ) + except FileNotFoundError: + return False + + +_GH_OK = _gh_available() +_SKIP_REASON = "gh CLI not authenticated — skip real project-status.py call" + REPO_ROOT = Path(__file__).resolve().parent.parent LOADER = REPO_ROOT / "tests" / "_ts_loader.mjs" TS_FILE = REPO_ROOT / ".opencode" / "tools" / "project-status.ts" @@ -150,6 +169,7 @@ def test_execute_uses_cwd_from_context(): ) +@pytest.mark.skipif(not _GH_OK, reason=_SKIP_REASON) def test_execute_real_project_status(): """Integration: execute() returns the real project-status.py output (non-blocking).""" if not (REPO_ROOT / ".opencode" / "scripts" / "project-status.py").exists():