mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
parent
07bb7e5a3b
commit
af0d8cda7b
4 changed files with 102 additions and 46 deletions
|
@ -168,3 +168,23 @@
|
|||
assert:
|
||||
that:
|
||||
- "shell_result4.changed == False"
|
||||
|
||||
- name: execute a shell command using a literal multiline block
|
||||
shell: |
|
||||
echo this is a
|
||||
"multiline echo"
|
||||
"with a new line
|
||||
in quotes"
|
||||
| md5sum
|
||||
| tr -s ' '
|
||||
| cut -f1 -d ' '
|
||||
register: shell_result5
|
||||
|
||||
- debug: var=shell_result5
|
||||
|
||||
- name: assert the multiline shell command ran as expected
|
||||
assert:
|
||||
that:
|
||||
- "shell_result5.changed"
|
||||
- "shell_result5.stdout == '32f3cc201b69ed8afa3902b80f554ca8'"
|
||||
|
||||
|
|
|
@ -158,4 +158,25 @@
|
|||
- name: assert that the directory was not changed
|
||||
assert:
|
||||
that:
|
||||
- "not copy_result5|changed"
|
||||
- "not copy_result5|changed"
|
||||
|
||||
# issue 8394
|
||||
- name: create a file with content and a literal multiline block
|
||||
copy: |
|
||||
content='this is the first line
|
||||
this is the second line
|
||||
|
||||
this line is after an empty line
|
||||
this line is the last line
|
||||
'
|
||||
dest={{output_dir}}/multiline.txt
|
||||
register: copy_result6
|
||||
|
||||
- debug: var=copy_result6
|
||||
|
||||
- name: assert the multiline file was created correctly
|
||||
assert:
|
||||
that:
|
||||
- "copy_result6.changed"
|
||||
- "copy_result6.dest == '{{output_dir|expanduser}}/multiline.txt'"
|
||||
- "copy_result6.md5sum == '1627d51e7e607c92cf1a502bf0c6cce3'"
|
||||
|
|
|
@ -705,8 +705,9 @@ class TestUtils(unittest.TestCase):
|
|||
# jinja2 loop blocks with lots of complexity
|
||||
_test_combo(
|
||||
# in memory of neighbors cat
|
||||
'a {% if x %} y {%else %} {{meow}} {% endif %} cookiechip\ndone',
|
||||
['a', '{% if x %}', 'y', '{%else %}', '{{meow}}', '{% endif %}', 'cookiechip\ndone']
|
||||
# we only preserve newlines inside of quotes
|
||||
'a {% if x %} y {%else %} {{meow}} {% endif %} "cookie\nchip"\ndone',
|
||||
['a', '{% if x %}', 'y', '{%else %}', '{{meow}}', '{% endif %}', '"cookie\nchip"', 'done']
|
||||
)
|
||||
|
||||
# test space preservation within quotes
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue