from pathlib import Path from scripts.adapters.actionlint import parse_actionlint_output _FIXTURES = Path(__file__).parent / "fixtures" def test_parses_findings(): payload = (_FIXTURES / "actionlint_sample.json").read_text() findings = parse_actionlint_output(payload) assert len(findings) == 2 def test_shellcheck_finding_fields(): payload = (_FIXTURES / "actionlint_sample.json").read_text() findings = parse_actionlint_output(payload) sc = next(f for f in findings if f.rule_id == "shellcheck") assert sc.tool == "actionlint" assert sc.severity == "high" assert sc.file == ".github/workflows/ci.yml" assert sc.line == 22 assert sc.end_line == 22 assert "SC2086" in sc.message def test_expression_finding_fields(): payload = (_FIXTURES / "actionlint_sample.json").read_text() findings = parse_actionlint_output(payload) expr = next(f for f in findings if f.rule_id == "expression") assert expr.line == 15 def test_handles_empty_array(): findings = parse_actionlint_output("[]") assert findings == [] def test_handles_invalid_json(): findings = parse_actionlint_output("not json") assert findings == []