mirror of https://github.com/ansible/ansible.git
Add new truthy and falsy jinja2 tests (#62602)
parent
918f768890
commit
594a0fa9ae
@ -0,0 +1,2 @@
|
|||||||
|
minor_changes:
|
||||||
|
- tests - Add new ``truthy`` and ``falsy`` jinja2 tests to evaluate the truthiness or falsiness of a value
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
shippable/posix/group2
|
||||||
|
skip/python2.6 # tests are controller only, and we no longer support Python 2.6 on the controller
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
- name: Assert truthy tests work
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- '"string" is truthy'
|
||||||
|
- '"" is not truthy'
|
||||||
|
- True is truthy
|
||||||
|
- False is not truthy
|
||||||
|
- true is truthy
|
||||||
|
- false is not truthy
|
||||||
|
- 1 is truthy
|
||||||
|
- 0 is not truthy
|
||||||
|
- '[""] is truthy'
|
||||||
|
- '[] is not truthy'
|
||||||
|
- '"on" is truthy(convert_bool=True)'
|
||||||
|
- '"off" is not truthy(convert_bool=True)'
|
||||||
|
- '{} is not truthy'
|
||||||
|
- '{"key": "value"} is truthy'
|
||||||
|
|
||||||
|
- name: Assert falsy tests work
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- '"string" is not falsy'
|
||||||
|
- '"" is falsy'
|
||||||
|
- True is not falsy
|
||||||
|
- False is falsy
|
||||||
|
- true is not falsy
|
||||||
|
- false is falsy
|
||||||
|
- 1 is not falsy
|
||||||
|
- 0 is falsy
|
||||||
|
- '[""] is not falsy'
|
||||||
|
- '[] is falsy'
|
||||||
|
- '"on" is not falsy(convert_bool=True)'
|
||||||
|
- '"off" is falsy(convert_bool=True)'
|
||||||
|
- '{} is falsy'
|
||||||
|
- '{"key": "value"} is not falsy'
|
||||||
Loading…
Reference in New Issue