Feat: init borgmatic role
This commit is contained in:
22
roles/borgmatic/molecule/default/tests/conftest.py
Normal file
22
roles/borgmatic/molecule/default/tests/conftest.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""PyTest Fixtures."""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def pytest_runtest_setup(item):
|
||||
"""Run tests only when under molecule with testinfra installed."""
|
||||
try:
|
||||
import testinfra
|
||||
except ImportError:
|
||||
pytest.skip("Test requires testinfra", allow_module_level=True)
|
||||
if "MOLECULE_INVENTORY_FILE" in os.environ:
|
||||
pytest.testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ["MOLECULE_INVENTORY_FILE"]
|
||||
).get_hosts("all")
|
||||
else:
|
||||
pytest.skip(
|
||||
"Test should run only from inside molecule.", allow_module_level=True
|
||||
)
|
||||
8
roles/borgmatic/molecule/default/tests/test_default.py
Normal file
8
roles/borgmatic/molecule/default/tests/test_default.py
Normal file
@@ -0,0 +1,8 @@
|
||||
"""Role testing files using testinfra."""
|
||||
import pytest
|
||||
|
||||
def test_installed_packages(host):
|
||||
borgbackup = host.package("borgbackup")
|
||||
assert borgbackup.is_installed
|
||||
borgmatic = host.package("borgmatic")
|
||||
assert borgmatic.is_installed
|
||||
Reference in New Issue
Block a user