Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/xml/tasks/test-xmlstring.yml

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 - name: Copy expected results to remote
7 copy:
8 src: "results/{{ item }}"
9 dest: "/tmp/{{ item }}"
10 with_items:
11 - test-pretty-print.xml
12 - test-pretty-print-only.xml
13
14 # NOTE: Jinja2 templating eats trailing newlines
15 - name: Read from xmlstring (not using pretty_print)
16 xml:
17 xmlstring: "{{ lookup('file', '{{ role_path }}/fixtures/ansible-xml-beers.xml') }}"
18 xpath: .
19 register: xmlresponse
20
21 - name: Compare to expected result
22 copy:
23 content: "{{ xmlresponse.xmlstring }}\n"
24 dest: '/tmp/test-pretty-print-only.xml'
25 check_mode: true
26 diff: true
27 register: comparison
28
29 - name: Test expected result
30 assert:
31 that:
32 - xmlresponse is not changed
33 - comparison is not changed # identical
34 # command: diff -u {{ role_path }}/results/test-pretty-print-only.xml /tmp/ansible-xml-beers.xml
35
36
37 # NOTE: Jinja2 templating eats trailing newlines
38 - name: Read from xmlstring (using pretty_print)
39 xml:
40 xmlstring: "{{ lookup('file', '{{ role_path }}/fixtures/ansible-xml-beers.xml') }}"
41 pretty_print: true
42 register: xmlresponse
43
44 - name: Compare to expected result
45 copy:
46 content: '{{ xmlresponse.xmlstring }}'
47 dest: '/tmp/test-pretty-print-only.xml'
48 check_mode: true
49 diff: true
50 register: comparison
51
52 # FIXME: This change is related to the newline added by pretty_print
53 - name: Test expected result
54 assert:
55 that:
56 - xmlresponse is changed
57 - comparison is not changed # identical
58 # command: diff -u {{ role_path }}/results/test-pretty-print-only.xml /tmp/ansible-xml-beers.xml
59
60
61 # NOTE: Jinja2 templating eats trailing newlines
62 - name: Read from xmlstring
63 xml:
64 xmlstring: "{{ lookup('file', '{{ role_path }}/fixtures/ansible-xml-beers.xml') }}"
65 xpath: /business/beers
66 pretty_print: true
67 add_children:
68 - beer: Old Rasputin
69 register: xmlresponse_modification
70
71 - name: Compare to expected result
72 copy:
73 content: '{{ xmlresponse_modification.xmlstring }}'
74 dest: '/tmp/test-pretty-print.xml'
75 check_mode: true
76 diff: true
77 register: comparison
78
79 # FIXME: This change is related to the newline added by pretty_print
80 - name: Test expected result
81 assert:
82 that:
83 - xmlresponse_modification is changed
84 - comparison is not changed # identical
85 # command: diff -u {{ role_path }}/results/test-pretty-print.xml /tmp/ansible-xml-beers.xml