Updated test

This commit is contained in:
David Murphy 2023-04-25 18:11:17 -06:00 committed by Gareth J. Greenaway
parent c63920b2f1
commit b78d771454

View file

@ -0,0 +1,42 @@
"""
Tests for payload
"""
import logging
import pytest
log = logging.getLogger(__name__)
@pytest.mark.slow_test
@pytest.mark.skip_if_not_root
@pytest.mark.skip_on_windows
@pytest.mark.skip_on_darwin
def test_payload_no_exception(salt_cli, salt_master, salt_minion):
"""
Test to confirm that no exception is thrown with the jinja file
when executed on the minion
"""
test_set_hostname = """
{%- set host = pillar.get("hostname", "UNKNOWN") %}
{%- if host == 'UNKNOWN' %}
{{ raise("Unsupported UNKNOWN hostname") }}
{%- else %}
hostnamectl set-hostname {{ host }}
{%- endif %}
"""
with salt_master.state_tree.base.temp_file("set_hostname.j2", test_set_hostname):
ret = salt_cli.run("test.ping", minion_tgt=salt_minion.id)
assert ret.returncode == 0
assert ret.data is True
ret = salt_cli.run(
"cmd.script",
"salt://set_hostname.j2",
"template=jinja",
pillar={"hostname": "test"},
minion_tgt=salt_minion.id,
)
log.warning(f"DGM output '{ret}'")
## assert not ret.stdout.startswith("Authentication failure")