diff --git a/tests/01_test_cli.py b/tests/01_test_cli.py index 7412e65..155fdb5 100644 --- a/tests/01_test_cli.py +++ b/tests/01_test_cli.py @@ -150,7 +150,9 @@ def test_test_incomplete(script_runner, script, config): 'one_minion_one_master', 'two_minions_one_master', 'one_minion_bootstrap', - 'one_minion_one_master_bootstrap' + 'one_minion_one_master_bootstrap', + 'one_minion_salt', + 'two_minions_one_master_salt' ]) def test_stop(script_runner, script, config, suite): cmd = (script, '--config', config, '--suite', suite, '--stop', '--force') diff --git a/tests/03_test_salt.py b/tests/03_test_salt.py index d9ef598..ac06703 100644 --- a/tests/03_test_salt.py +++ b/tests/03_test_salt.py @@ -28,3 +28,32 @@ def test_salt(script_runner, script, config, suite): assert 'DEBUG - main_interactive: state.apply requested' in result.stderr assert script_runner.run(*cmd, '--stop') +@pytest.mark.parametrize('config', ['complete'], indirect=True) +@pytest.mark.parametrize('suite,count', [ + ('one_minion_salt', 0), + ('two_minions_one_master_salt', 1) + ]) +def test_salt_test(script_runner, script, config, suite, count): + cmd = (script, '--config', config, '--suite', suite) + result = script_runner.run(*cmd, '--debug', '--env', '--test') + assert result.success + for message in [ + 'Comment: File /srv/hello_world.txt updated', + 'Succeeded: 1 (changed=1)', + 'DEBUG - main_interactive: state.apply requested', + 'INFO - main_interactive: Initiating tests ...', + 'DEBUG - runtests: Test result is 0', + 'DEBUG - runtests: Test succeeded' + ]: + assert message in result.stderr + assert not any(term in result.stderr for term in [ + 'FAILED', 'WARNING - runtests: Tests failed', + 'DEBUG - runtests: Test result is 1', 'AssertionError' + ]) + if count > 0: + minions = [0, 1] + else: + minions = [0] + for m in minions: + assert 'test_hello_world_content[paramiko://scullery-minion%i] PASSED' % m in result.stdout + assert script_runner.run(*cmd, '--stop') diff --git a/tests/configs/complete.ini b/tests/configs/complete.ini index fdee52b..0f29c07 100644 --- a/tests/configs/complete.ini +++ b/tests/configs/complete.ini @@ -56,7 +56,7 @@ test=bogus [test.hello] apply=hello_world -test=salt/hello_world/tests/test_hello.py +test=tests/salt/hello_world/tests/test_hello.py [test.bogus] apply=cashew diff --git a/tests/salt/hello_world/tests/test_hello.py b/tests/salt/hello_world/tests/test_hello.py new file mode 100644 index 0000000..4cab978 --- /dev/null +++ b/tests/salt/hello_world/tests/test_hello.py @@ -0,0 +1,2 @@ +def test_hello_world_content(host): + assert host.file('/srv/hello_world.txt').content.decode('UTF-8') == 'Hello salted world!\n'