mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
test for file.apply_template_on_contents
This commit is contained in:
parent
10d882296d
commit
dcd6f5a5a9
1 changed files with 23 additions and 1 deletions
|
@ -25,7 +25,12 @@ filemod.__salt__ = {
|
|||
'cmd.run': cmdmod.run,
|
||||
'cmd.run_all': cmdmod.run_all
|
||||
}
|
||||
filemod.__opts__ = {'test': False}
|
||||
filemod.__opts__ = {
|
||||
'test': False,
|
||||
'file_roots': {'base': 'tmp'},
|
||||
'pillar_roots': {'base': 'tmp'},
|
||||
'cachedir': 'tmp',
|
||||
}
|
||||
|
||||
SED_CONTENT = """test
|
||||
some
|
||||
|
@ -34,6 +39,9 @@ content
|
|||
here
|
||||
"""
|
||||
|
||||
filemod.__grains__ = {}
|
||||
filemod.__pillar__ = {}
|
||||
|
||||
|
||||
class FileReplaceTestCase(TestCase):
|
||||
MULTILINE_STRING = textwrap.dedent('''\
|
||||
|
@ -516,6 +524,20 @@ class FileModuleTestCase(TestCase):
|
|||
ret = filemod.group_to_gid(group)
|
||||
self.assertEqual(ret, group)
|
||||
|
||||
def test_apply_template_on_contents(self):
|
||||
'''
|
||||
Tests that the templating engine works on string contents
|
||||
'''
|
||||
contents = 'This is a {{ template }}.'
|
||||
defaults = {'template': 'templated file'}
|
||||
ret = filemod.apply_template_on_contents(
|
||||
contents,
|
||||
template='jinja',
|
||||
context={'opts': filemod.__opts__},
|
||||
defaults=defaults,
|
||||
saltenv='base')
|
||||
self.assertEqual(ret, 'This is a templated file.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
|
|
Loading…
Add table
Reference in a new issue