2017-08-09 05:21:03 +02:00
|
|
|
---
|
2019-01-25 04:25:06 +01: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 02:07:58 +02:00
|
|
|
# NOTE: Jinja2 templating eats trailing newlines
|
|
|
|
- name: Read from xmlstring (not using pretty_print)
|
2017-08-09 05:21:03 +02:00
|
|
|
xml:
|
|
|
|
xmlstring: "{{ lookup('file', '{{ role_path }}/fixtures/ansible-xml-beers.xml') }}"
|
2017-08-25 02:07:58 +02:00
|
|
|
xpath: .
|
2017-08-09 05:21:03 +02:00
|
|
|
register: xmlresponse
|
2017-08-25 02:07:58 +02:00
|
|
|
|
|
|
|
- name: Compare to expected result
|
|
|
|
copy:
|
|
|
|
content: "{{ xmlresponse.xmlstring }}\n"
|
2019-01-25 04:25:06 +01:00
|
|
|
dest: '/tmp/test-pretty-print-only.xml'
|
2017-08-25 02:07:58 +02: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 05:21:03 +02:00
|
|
|
copy:
|
2017-08-25 02:07:58 +02:00
|
|
|
content: '{{ xmlresponse.xmlstring }}'
|
2019-01-25 04:25:06 +01:00
|
|
|
dest: '/tmp/test-pretty-print-only.xml'
|
2017-08-25 02:07:58 +02:00
|
|
|
check_mode: yes
|
|
|
|
diff: yes
|
|
|
|
register: comparison
|
2017-08-09 05:21:03 +02:00
|
|
|
|
2017-08-25 02:07:58 +02:00
|
|
|
# FIXME: This change is related to the newline added by pretty_print
|
2017-08-09 05:21:03 +02:00
|
|
|
- name: Test expected result
|
2017-08-25 02:07:58 +02: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 05:21:03 +02:00
|
|
|
|
2017-08-25 02:07:58 +02:00
|
|
|
# NOTE: Jinja2 templating eats trailing newlines
|
2017-08-09 05:21:03 +02:00
|
|
|
- name: Read from xmlstring
|
|
|
|
xml:
|
|
|
|
xmlstring: "{{ lookup('file', '{{ role_path }}/fixtures/ansible-xml-beers.xml') }}"
|
|
|
|
xpath: /business/beers
|
2017-08-25 02:07:58 +02:00
|
|
|
pretty_print: yes
|
2017-08-09 05:21:03 +02:00
|
|
|
add_children:
|
2017-08-25 02:07:58 +02:00
|
|
|
- beer: Old Rasputin
|
2017-08-09 05:21:03 +02:00
|
|
|
register: xmlresponse_modification
|
|
|
|
|
2017-08-25 02:07:58 +02:00
|
|
|
- name: Compare to expected result
|
2017-08-09 05:21:03 +02:00
|
|
|
copy:
|
2017-08-25 02:07:58 +02:00
|
|
|
content: '{{ xmlresponse_modification.xmlstring }}'
|
2019-01-25 04:25:06 +01:00
|
|
|
dest: '/tmp/test-pretty-print.xml'
|
2017-08-25 02:07:58 +02:00
|
|
|
check_mode: yes
|
|
|
|
diff: yes
|
|
|
|
register: comparison
|
2017-08-09 05:21:03 +02:00
|
|
|
|
2017-08-25 02:07:58 +02:00
|
|
|
# FIXME: This change is related to the newline added by pretty_print
|
2017-08-09 05:21:03 +02:00
|
|
|
- name: Test expected result
|
2017-08-25 02:07:58 +02: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
|