From 1faea9a6c75f33109e8f66b57b432fdad57b3f46 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 26 Jun 2024 08:24:57 +0200 Subject: Adding upstream version 24.6.1. Signed-off-by: Daniel Baumann --- test/test_examples.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'test/test_examples.py') 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, -- cgit v1.2.3