Feat: init refact with test
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
22
roles/dotfiles/molecule/default/tests/conftest.py
Normal file
22
roles/dotfiles/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
|
||||
)
|
||||
23
roles/dotfiles/molecule/default/tests/test_default.py
Normal file
23
roles/dotfiles/molecule/default/tests/test_default.py
Normal file
@@ -0,0 +1,23 @@
|
||||
"""Role testing files using testinfra."""
|
||||
|
||||
|
||||
def test_stow_installed(host):
|
||||
stow = host.package("stow")
|
||||
assert stow.is_installed
|
||||
|
||||
def test_dotfile_cloned(host):
|
||||
homepath = host.run("pwd").stdout[:-1]
|
||||
dotfiles = host.file(homepath + "/.dotfiles")
|
||||
assert dotfiles.exists
|
||||
|
||||
def test_dotfile_stowed(host):
|
||||
homepath = host.run("pwd").stdout[:-1]
|
||||
nvim = host.file(homepath + "/.config/nvim/")
|
||||
assert nvim.exists
|
||||
tmux = host.file(homepath + "/.tmux/")
|
||||
assert tmux.exists
|
||||
zshenv = host.file(homepath + "/.zshenv")
|
||||
assert zshenv.exists
|
||||
zsh = host.file(homepath + "/.config/zsh/")
|
||||
assert zsh.exists
|
||||
|
||||
Reference in New Issue
Block a user