summaryrefslogtreecommitdiffstats
path: root/test/rules/test_package_latest.py
blob: 5631f02b7031e580b04df8bad4c79ea20636e94f (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 package-latest rule."""
from ansiblelint.rules import RulesCollection
from ansiblelint.rules.package_latest import PackageIsNotLatestRule
from ansiblelint.runner import Runner


def test_package_not_latest_positive() -> None:
    """Positive test for package-latest."""
    collection = RulesCollection()
    collection.register(PackageIsNotLatestRule())
    success = "examples/playbooks/package-check-success.yml"
    good_runner = Runner(success, rules=collection)
    assert [] == good_runner.run()


def test_package_not_latest_negative() -> None:
    """Negative test for package-latest."""
    collection = RulesCollection()
    collection.register(PackageIsNotLatestRule())
    failure = "examples/playbooks/package-check-failure.yml"
    bad_runner = Runner(failure, rules=collection)
    errs = bad_runner.run()
    assert len(errs) == 4