summaryrefslogtreecommitdiffstats
path: root/test/test_examples.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-26 06:24:57 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-26 06:24:57 +0000
commit1faea9a6c75f33109e8f66b57b432fdad57b3f46 (patch)
tree4184ce38ac0cf9d5a46bbbae03c87be82927f12b /test/test_examples.py
parentAdding upstream version 6.17.2. (diff)
downloadansible-lint-upstream.tar.xz
ansible-lint-upstream.zip
Adding upstream version 24.6.1.upstream/24.6.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/test_examples.py')
-rw-r--r--test/test_examples.py35
1 files changed, 21 insertions, 14 deletions
diff --git a/test/test_examples.py b/test/test_examples.py
index 2842930..7840360 100644
--- a/test/test_examples.py
+++ b/test/test_examples.py
@@ -1,4 +1,5 @@
"""Assure samples produced desire outcomes."""
+
import pytest
from ansiblelint.app import get_app
@@ -17,31 +18,37 @@ def test_example(default_rules_collection: RulesCollection) -> None:
@pytest.mark.parametrize(
- ("filename", "line", "column"),
+ ("filename", "expected_results"),
(
pytest.param(
"examples/playbooks/syntax-error-string.yml",
- 6,
- 7,
- id="syntax-error",
+ [("syntax-check[unknown-module]", 6, 7)],
+ id="0",
+ ),
+ pytest.param(
+ "examples/playbooks/syntax-error.yml",
+ [("syntax-check[specific]", 2, 3)],
+ id="1",
),
- pytest.param("examples/playbooks/syntax-error.yml", 2, 3, id="syntax-error"),
),
)
def test_example_syntax_error(
default_rules_collection: RulesCollection,
filename: str,
- line: int,
- column: int,
+ expected_results: list[tuple[str, int | None, int | None]],
) -> None:
"""Validates that loading valid YAML string produce error."""
result = Runner(filename, rules=default_rules_collection).run()
- assert len(result) == 1
- assert result[0].rule.id == "syntax-check"
- # This also ensures that line and column numbers start at 1, so they
- # match what editors will show (or output from other linters)
- assert result[0].lineno == line
- assert result[0].column == column
+ assert len(result) == len(expected_results)
+ for i, expected in enumerate(expected_results):
+ if expected[0] is not None:
+ assert result[i].tag == expected[0]
+ # This also ensures that line and column numbers start at 1, so they
+ # match what editors will show (or output from other linters)
+ if expected[1] is not None:
+ assert result[i].lineno == expected[1]
+ if expected[2] is not None:
+ assert result[i].column == expected[2]
def test_example_custom_module(default_rules_collection: RulesCollection) -> None:
@@ -67,7 +74,7 @@ def test_vault_partial(
default_rules_collection: RulesCollection,
caplog: pytest.LogCaptureFixture,
) -> None:
- """Check ability to precess files that container !vault inside."""
+ """Check ability to process files that container !vault inside."""
result = Runner(
"examples/playbooks/vars/vault_partial.yml",
rules=default_rules_collection,