2017-08-09 03:21:03 +00:00
|
|
|
---
|
2019-01-25 03:25:06 +00:00
|
|
|
- name: Copy expected results to remote
|
|
|
|
copy:
|
|
|
|
src: "results/{{ item }}"
|
|
|
|
dest: "/tmp/{{ item }}"
|
|
|
|
with_items:
|
|
|
|
- test-pretty-print.xml
|
|
|
|
- test-pretty-print-only.xml
|
|
|
|
|
2017-08-25 00:07:58 +00:00
|
|
|
# NOTE: Jinja2 templating eats trailing newlines
|
|
|
|
- name: Read from xmlstring (not using pretty_print)
|
2017-08-09 03:21:03 +00:00
|
|
|
xml:
|
|
|
|
xmlstring: "{{ lookup('file', '{{ role_path }}/fixtures/ansible-xml-beers.xml') }}"
|
2017-08-25 00:07:58 +00:00
|
|
|
xpath: .
|
2017-08-09 03:21:03 +00:00
|
|
|
register: xmlresponse
|
2017-08-25 00:07:58 +00:00
|
|
|
|
|
|
|
- name: Compare to expected result
|
|
|
|
copy:
|
|
|
|
content: "{{ xmlresponse.xmlstring }}\n"
|
2019-01-25 03:25:06 +00:00
|
|
|
dest: '/tmp/test-pretty-print-only.xml'
|
2017-08-25 00:07:58 +00:00
|
|
|
check_mode: yes
|
|
|
|
diff: yes
|
|
|
|
register: comparison
|
|
|
|
|
|
|
|
- name: Test expected result
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- xmlresponse.changed == false
|
|
|
|
- comparison.changed == false # identical
|
|
|
|
#command: diff -u {{ role_path }}/results/test-pretty-print-only.xml /tmp/ansible-xml-beers.xml
|
|
|
|
|
|
|
|
|
|
|
|
# NOTE: Jinja2 templating eats trailing newlines
|
|
|
|
- name: Read from xmlstring (using pretty_print)
|
|
|
|
xml:
|
|
|
|
xmlstring: "{{ lookup('file', '{{ role_path }}/fixtures/ansible-xml-beers.xml') }}"
|
|
|
|
pretty_print: yes
|
|
|
|
register: xmlresponse
|
|
|
|
|
|
|
|
- name: Compare to expected result
|
2017-08-09 03:21:03 +00:00
|
|
|
copy:
|
2017-08-25 00:07:58 +00:00
|
|
|
content: '{{ xmlresponse.xmlstring }}'
|
2019-01-25 03:25:06 +00:00
|
|
|
dest: '/tmp/test-pretty-print-only.xml'
|
2017-08-25 00:07:58 +00:00
|
|
|
check_mode: yes
|
|
|
|
diff: yes
|
|
|
|
register: comparison
|
2017-08-09 03:21:03 +00:00
|
|
|
|
2017-08-25 00:07:58 +00:00
|
|
|
# FIXME: This change is related to the newline added by pretty_print
|
2017-08-09 03:21:03 +00:00
|
|
|
- name: Test expected result
|
2017-08-25 00:07:58 +00:00
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- xmlresponse.changed == true
|
|
|
|
- comparison.changed == false # identical
|
|
|
|
#command: diff -u {{ role_path }}/results/test-pretty-print-only.xml /tmp/ansible-xml-beers.xml
|
|
|
|
|
2017-08-09 03:21:03 +00:00
|
|
|
|
2017-08-25 00:07:58 +00:00
|
|
|
# NOTE: Jinja2 templating eats trailing newlines
|
2017-08-09 03:21:03 +00:00
|
|
|
- name: Read from xmlstring
|
|
|
|
xml:
|
|
|
|
xmlstring: "{{ lookup('file', '{{ role_path }}/fixtures/ansible-xml-beers.xml') }}"
|
|
|
|
xpath: /business/beers
|
2017-08-25 00:07:58 +00:00
|
|
|
pretty_print: yes
|
2017-08-09 03:21:03 +00:00
|
|
|
add_children:
|
2017-08-25 00:07:58 +00:00
|
|
|
- beer: Old Rasputin
|
2017-08-09 03:21:03 +00:00
|
|
|
register: xmlresponse_modification
|
|
|
|
|
2017-08-25 00:07:58 +00:00
|
|
|
- name: Compare to expected result
|
2017-08-09 03:21:03 +00:00
|
|
|
copy:
|
2017-08-25 00:07:58 +00:00
|
|
|
content: '{{ xmlresponse_modification.xmlstring }}'
|
2019-01-25 03:25:06 +00:00
|
|
|
dest: '/tmp/test-pretty-print.xml'
|
2017-08-25 00:07:58 +00:00
|
|
|
check_mode: yes
|
|
|
|
diff: yes
|
|
|
|
register: comparison
|
2017-08-09 03:21:03 +00:00
|
|
|
|
2017-08-25 00:07:58 +00:00
|
|
|
# FIXME: This change is related to the newline added by pretty_print
|
2017-08-09 03:21:03 +00:00
|
|
|
- name: Test expected result
|
2017-08-25 00:07:58 +00:00
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- xmlresponse_modification.changed == true
|
|
|
|
- comparison.changed == false # identical
|
|
|
|
#command: diff -u {{ role_path }}/results/test-pretty-print.xml /tmp/ansible-xml-beers.xml
|