Coverage for tests / unit / parsers / test_actionlint_parser.py: 100%
21 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-04-03 18:53 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-04-03 18:53 +0000
1"""Unit tests for the Actionlint output parser.
3These tests validate that the parser handles empty output and typical
4``file:line:col: level: message [CODE]`` lines, producing structured issues.
5"""
7from assertpy import assert_that
9from lintro.parsers.actionlint.actionlint_parser import parse_actionlint_output
12def test_parse_actionlint_empty() -> None:
13 """Return an empty list for empty parser input."""
14 assert_that(parse_actionlint_output("")).is_equal_to([])
17def test_parse_actionlint_lines() -> None:
18 """Parse typical actionlint lines and produce structured issues."""
19 out = (
20 "workflow.yml:10:5: error: unexpected key [AL100]\n"
21 "workflow.yml:12:3: warning: something minor"
22 )
23 issues = parse_actionlint_output(out)
24 assert_that(len(issues)).is_equal_to(2)
25 i0 = issues[0]
26 assert_that(i0.file).is_equal_to("workflow.yml")
27 assert_that(i0.line).is_equal_to(10)
28 assert_that(i0.column).is_equal_to(5)
29 assert_that(i0.level).is_equal_to("error")
30 assert_that(i0.code).is_equal_to("AL100")
31 assert_that(i0.message).contains("unexpected key")
34def test_parse_actionlint_ansi_codes_stripped() -> None:
35 """Strip ANSI escape codes from output for consistent CI/local parsing."""
36 # Output with ANSI color codes (common in CI environments)
37 output = "\x1b[31mworkflow.yml:10:5: error: unexpected key [AL100]\x1b[0m"
38 issues = parse_actionlint_output(output)
39 assert_that(len(issues)).is_equal_to(1)
40 assert_that(issues[0].file).is_equal_to("workflow.yml")
41 assert_that(issues[0].code).is_equal_to("AL100")