mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Migrate test to functional
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
parent
d86debf2ee
commit
f9d7d117f8
2 changed files with 81 additions and 94 deletions
|
@ -125,3 +125,84 @@ def test_issue_11003_immutable_lazy_proxy_sum(modules, tmp_path, state_tree):
|
|||
for item in ("", "bar", "baz"):
|
||||
block_contents.remove(item)
|
||||
assert block_contents == []
|
||||
|
||||
|
||||
def test_issue_60426(modules, tmp_path, state_tree):
|
||||
target_path = tmp_path.joinpath("etc/foo/bar")
|
||||
jinja_name = "foo_bar"
|
||||
jinja_contents = (
|
||||
"{% for item in accumulator['accumulated configstuff'] %}{{ item }}{% endfor %}"
|
||||
)
|
||||
|
||||
sls_name = "issue-60426"
|
||||
sls_contents = f"""
|
||||
configuration file:
|
||||
file.managed:
|
||||
- name: {target_path}
|
||||
- source: salt://foo_bar.jinja
|
||||
- template: jinja
|
||||
- makedirs: True
|
||||
|
||||
accumulated configstuff:
|
||||
file.accumulated:
|
||||
- filename: {target_path}
|
||||
- text:
|
||||
- some
|
||||
- good
|
||||
- stuff
|
||||
- watch_in:
|
||||
- configuration file
|
||||
"""
|
||||
|
||||
sls_tempfile = pytest.helpers.temp_file(
|
||||
f"{sls_name}.sls", directory=state_tree, contents=sls_contents
|
||||
)
|
||||
|
||||
jinja_tempfile = pytest.helpers.temp_file(
|
||||
f"{jinja_name}.jinja", directory=state_tree, contents=jinja_contents
|
||||
)
|
||||
|
||||
with sls_tempfile, jinja_tempfile:
|
||||
ret = modules.state.apply(sls_name)
|
||||
for state_run in ret:
|
||||
assert state_run.result is True
|
||||
# Check to make sure the file was created
|
||||
assert target_path.is_file()
|
||||
# The type of new line, ie, `\n` vs `\r\n` is not important
|
||||
assert target_path.read_text() == "somegoodstuff"
|
||||
|
||||
sls_contents = f"""
|
||||
configuration file:
|
||||
file.managed:
|
||||
- name: {target_path}
|
||||
- source: salt://foo_bar.jinja
|
||||
- template: jinja
|
||||
- makedirs: True
|
||||
|
||||
accumulated configstuff:
|
||||
file.accumulated:
|
||||
- filename: {target_path}
|
||||
- text:
|
||||
- some
|
||||
- more
|
||||
- good
|
||||
- stuff
|
||||
- watch_in:
|
||||
- file: configuration file
|
||||
"""
|
||||
|
||||
sls_tempfile = pytest.helpers.temp_file(
|
||||
f"{sls_name}.sls", directory=state_tree, contents=sls_contents
|
||||
)
|
||||
jinja_tempfile = pytest.helpers.temp_file(
|
||||
f"{jinja_name}.jinja", directory=state_tree, contents=jinja_contents
|
||||
)
|
||||
|
||||
with sls_tempfile, jinja_tempfile:
|
||||
ret = modules.state.apply(sls_name)
|
||||
for state_run in ret:
|
||||
assert state_run.result is True
|
||||
# Check to make sure the file was created
|
||||
assert target_path.is_file()
|
||||
# The type of new line, ie, `\n` vs `\r\n` is not important
|
||||
assert target_path.read_text() == "somemoregoodstuff"
|
||||
|
|
|
@ -384,100 +384,6 @@ def test_issue_50221(
|
|||
assert target_path.read_text().replace("\r\n", "\n") == expected_content
|
||||
|
||||
|
||||
def test_issue_60426(
|
||||
salt_master,
|
||||
salt_call_cli,
|
||||
tmp_path,
|
||||
):
|
||||
target_path = tmp_path.joinpath("etc/foo/bar")
|
||||
jinja_name = "foo_bar"
|
||||
jinja_contents = (
|
||||
"{% for item in accumulator['accumulated configstuff'] %}{{ item }}{% endfor %}"
|
||||
)
|
||||
|
||||
sls_name = "issue-60426"
|
||||
sls_contents = """
|
||||
configuration file:
|
||||
file.managed:
|
||||
- name: {target_path}
|
||||
- source: salt://foo_bar.jinja
|
||||
- template: jinja
|
||||
- makedirs: True
|
||||
|
||||
accumulated configstuff:
|
||||
file.accumulated:
|
||||
- filename: {target_path}
|
||||
- text:
|
||||
- some
|
||||
- good
|
||||
- stuff
|
||||
- watch_in:
|
||||
- configuration file
|
||||
""".format(
|
||||
target_path=target_path
|
||||
)
|
||||
|
||||
sls_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.sls".format(sls_name), sls_contents
|
||||
)
|
||||
|
||||
jinja_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.jinja".format(jinja_name), jinja_contents
|
||||
)
|
||||
|
||||
with sls_tempfile, jinja_tempfile:
|
||||
ret = salt_call_cli.run("state.apply", sls_name)
|
||||
assert ret.returncode == 0
|
||||
assert ret.data
|
||||
state_run = next(iter(ret.data.values()))
|
||||
assert state_run["result"] is True
|
||||
# Check to make sure the file was created
|
||||
assert target_path.is_file()
|
||||
# The type of new line, ie, `\n` vs `\r\n` is not important
|
||||
assert target_path.read_text() == "somegoodstuff"
|
||||
|
||||
sls_name = "issue-60426"
|
||||
sls_contents = """
|
||||
configuration file:
|
||||
file.managed:
|
||||
- name: {target_path}
|
||||
- source: salt://foo_bar.jinja
|
||||
- template: jinja
|
||||
- makedirs: True
|
||||
|
||||
accumulated configstuff:
|
||||
file.accumulated:
|
||||
- filename: {target_path}
|
||||
- text:
|
||||
- some
|
||||
- more
|
||||
- good
|
||||
- stuff
|
||||
- watch_in:
|
||||
- file: configuration file
|
||||
""".format(
|
||||
target_path=target_path
|
||||
)
|
||||
|
||||
sls_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.sls".format(sls_name), sls_contents
|
||||
)
|
||||
jinja_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.jinja".format(jinja_name), jinja_contents
|
||||
)
|
||||
|
||||
with sls_tempfile, jinja_tempfile:
|
||||
ret = salt_call_cli.run("state.apply", sls_name)
|
||||
assert ret.returncode == 0
|
||||
assert ret.data
|
||||
state_run = next(iter(ret.data.values()))
|
||||
assert state_run["result"] is True
|
||||
# Check to make sure the file was created
|
||||
assert target_path.is_file()
|
||||
# The type of new line, ie, `\n` vs `\r\n` is not important
|
||||
assert target_path.read_text() == "somemoregoodstuff"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def _check_min_patch_version(shell):
|
||||
min_patch_ver = "2.6"
|
||||
|
|
Loading…
Add table
Reference in a new issue