Private
Public Access
feat(report): implement write_failure_report + 8 tests, 100% coverage
This commit is contained in:
@@ -85,3 +85,36 @@ def test_stopped_flag_created(monkeypatch, tmp_path) -> None:
|
||||
)
|
||||
flag = compute_stopped_flag_path("my_track")
|
||||
assert flag.exists()
|
||||
|
||||
|
||||
def test_recommend_green_phase_stuck() -> None:
|
||||
from scripts.tier2.write_report import _recommend
|
||||
state = FailcountState(red_phase_failures=0, green_phase_failures=3)
|
||||
rec = _recommend(state, None)
|
||||
assert "green-phase" in rec.lower()
|
||||
|
||||
|
||||
def test_truncate_long_text() -> None:
|
||||
from scripts.tier2.write_report import _truncate
|
||||
long_text = "\n".join(f"line {i}" for i in range(100))
|
||||
truncated = _truncate(long_text, max_lines=10)
|
||||
assert "line 0" in truncated
|
||||
assert "line 9" in truncated
|
||||
assert "truncated" in truncated
|
||||
assert "90 more lines" in truncated
|
||||
|
||||
|
||||
def test_truncate_short_text_unchanged() -> None:
|
||||
from scripts.tier2.write_report import _truncate
|
||||
text = "short\ntext"
|
||||
assert _truncate(text) == text
|
||||
|
||||
|
||||
def test_git_log_fallback_on_subprocess_error(monkeypatch, tmp_path) -> None:
|
||||
from scripts.tier2.write_report import _git_log_for_branch
|
||||
import scripts.tier2.write_report as wr
|
||||
def fake_run(*args, **kwargs):
|
||||
raise FileNotFoundError("no git")
|
||||
monkeypatch.setattr(wr.subprocess, "run", fake_run)
|
||||
result = _git_log_for_branch("any", tmp_path)
|
||||
assert "not available" in result.lower()
|
||||
|
||||
Reference in New Issue
Block a user