mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 04:11:25 -07:00
Fix ${var.$other_var} and add test cases for it
This commit is contained in:
parent
fb27cb45e1
commit
efe83daf19
2 changed files with 25 additions and 3 deletions
|
@ -238,6 +238,28 @@ class TestUtils(unittest.TestCase):
|
|||
res = ansible.utils.varReplace(template, vars)
|
||||
assert res == 'action $foo'
|
||||
|
||||
def test_varReplace_var_part(self):
|
||||
vars = {
|
||||
'foo': {
|
||||
'bar': 'result',
|
||||
},
|
||||
'key': 'bar',
|
||||
}
|
||||
template = 'test ${foo.$key}'
|
||||
res = ansible.utils.varReplace(template, vars)
|
||||
assert res == 'test result'
|
||||
|
||||
def test_varReplace_var_partial_part(self):
|
||||
vars = {
|
||||
'foo': {
|
||||
'barbaz': 'result',
|
||||
},
|
||||
'key': 'bar',
|
||||
}
|
||||
template = 'test ${foo.${key}baz}'
|
||||
res = ansible.utils.varReplace(template, vars)
|
||||
assert res == 'test result'
|
||||
|
||||
def test_template_varReplace_iterated(self):
|
||||
template = 'hello $who'
|
||||
vars = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue