mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add pytest helper to create temporary pillar files
This commit is contained in:
parent
14e606b39c
commit
3f77f6eb28
1 changed files with 16 additions and 0 deletions
|
@ -708,6 +708,22 @@ def temp_state_file(name, contents, saltenv="base", strip_first_newline=True):
|
|||
)
|
||||
|
||||
|
||||
@pytest.helpers.register
|
||||
def temp_pillar_file(name, contents, saltenv="base", strip_first_newline=True):
|
||||
|
||||
if saltenv == "base":
|
||||
directory = RUNTIME_VARS.TMP_PILLAR_TREE
|
||||
elif saltenv == "prod":
|
||||
directory = RUNTIME_VARS.TMP_PRODENV_PILLAR_TREE
|
||||
else:
|
||||
raise RuntimeError(
|
||||
'"saltenv" can only be "base" or "prod", not "{}"'.format(saltenv)
|
||||
)
|
||||
return temp_file(
|
||||
name, contents, directory=directory, strip_first_newline=strip_first_newline
|
||||
)
|
||||
|
||||
|
||||
# <---- Pytest Helpers -----------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue