Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cognifloyd committed Nov 17, 2020
1 parent dd420e5 commit 3e04535
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/molecule/test/unit/command/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ def _patched_sysexit(mocker):
return mocker.patch("molecule.util.sysexit")


@pytest.fixture
def _patched_ci_env(request, monkeypatch):
"""Parametrize tests with and without CI env vars."""
envvars = {"CI": None, "TRAVIS": None, "GITHUB_ACTIONS": None, "GITLAB_CI": None}
envvars.update(request.param)
for envvar, value in envvars.items():
if value is None:
monkeypatch.delenv(envvar, raising=False)
else:
monkeypatch.setenv(envvar, value)


def test_config_private_member(_instance):
assert isinstance(_instance._config, config.Config)

Expand Down Expand Up @@ -213,8 +225,17 @@ def test_execute_cmdline_scenarios_exit_nodestroy(
assert not _patched_prune.called
assert not _patched_sysexit.called


def test_execute_subcommand(config_instance):
@pytest.mark.parametrize(
"_patched_ci_env",
[
{},
{"CI": "true", "TRAVIS": "true"},
{"CI": "true", "GITHUB_ACTIONS": "true"},
{"CI": "true", "GITLAB_CI": "true"},
],
indirect=True,
)
def test_execute_subcommand(config_instance, _patched_ci_env):
# scenario's config.action is mutated in-place for every sequence action,
# so make sure that is currently set to the executed action
assert config_instance.action != "list"
Expand Down

0 comments on commit 3e04535

Please sign in to comment.