1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-07-08 19:49:09 +00:00
community.general/tests/integration/targets/xml/tasks/test-print-match.yml
patchback[bot] bb539f1d56
[PR #12013/abef8f2a backport][stable-12] xml: fix print_match not populating matches return value (#12021)
xml: fix `print_match` not populating `matches` return value (#12013)

* fix(xml): populate matches when print_match is set, fix returned doc



* test(xml): add integration tests for print_match



* changelog: add fragment for PR 12013



---------


(cherry picked from commit abef8f2aed)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-10 10:22:16 +02:00

38 lines
1.2 KiB
YAML

---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- name: Setup test fixture
copy:
src: fixtures/ansible-xml-beers.xml
dest: /tmp/ansible-xml-beers.xml
- name: print_match returns matching xpath paths in matches
xml:
path: /tmp/ansible-xml-beers.xml
xpath: /business/beers/beer
print_match: true
register: print_match_result
- name: Test expected result
assert:
that:
- print_match_result is not changed
- print_match_result.matches | length == 3
- "'/business/beers/beer[1]' in print_match_result.matches"
- "'/business/beers/beer[2]' in print_match_result.matches"
- "'/business/beers/beer[3]' in print_match_result.matches"
- name: print_match with no matches returns empty matches list
xml:
path: /tmp/ansible-xml-beers.xml
xpath: /business/nonexistent
print_match: true
register: print_match_empty
- name: Test expected result for no matches
assert:
that:
- print_match_empty is not changed
- print_match_empty.matches | length == 0