summaryrefslogtreecommitdiffstats
path: root/test/rules/test_no_changed_when.py
blob: c89d8f4c3671cf2148cb7c296a4c104e121d5fdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Tests for no-change-when rule."""
from ansiblelint.rules import RulesCollection
from ansiblelint.rules.no_changed_when import CommandHasChangesCheckRule
from ansiblelint.runner import Runner


def test_command_changes_positive() -> None:
    """Positive test for no-changed-when."""
    collection = RulesCollection()
    collection.register(CommandHasChangesCheckRule())
    success = "examples/playbooks/command-check-success.yml"
    good_runner = Runner(success, rules=collection)
    assert [] == good_runner.run()


def test_command_changes_negative() -> None:
    """Negative test for no-changed-when."""
    collection = RulesCollection()
    collection.register(CommandHasChangesCheckRule())
    failure = "examples/playbooks/command-check-failure.yml"
    bad_runner = Runner(failure, rules=collection)
    errs = bad_runner.run()
    assert len(errs) == 2