mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Fix only_if statements referencing non-string types
This fixes e.g. only_if: ${task.changed} which would always
evaluate to true due to it having been replaced by a string for its
boolean value. Also adds a test case to ensure it doesn't get
missed again.
This commit is contained in:
@@ -251,6 +251,16 @@ class TestUtils(unittest.TestCase):
|
||||
res = ansible.utils.varReplace(template, vars, do_repr=True)
|
||||
assert eval(res)
|
||||
|
||||
def test_varReplace_repr_nonstr(self):
|
||||
vars = {
|
||||
'foo': True,
|
||||
'bar': 1L,
|
||||
}
|
||||
|
||||
template = '${foo} == $bar'
|
||||
res = ansible.utils.varReplace(template, vars, do_repr=True)
|
||||
assert res == 'True == 1L'
|
||||
|
||||
def test_template_varReplace_iterated(self):
|
||||
template = 'hello $who'
|
||||
vars = {
|
||||
|
||||
Reference in New Issue
Block a user