summaryrefslogtreecommitdiffstats
path: root/test/integration/targets
diff options
context:
space:
mode:
authorJames Ramsaran <45861913+MooseAnthem@users.noreply.github.com>2024-11-14 04:46:57 +0100
committerGitHub <noreply@github.com>2024-11-14 04:46:57 +0100
commite14f9fe725e1fb1cf37a0aac932d9b9c1f1c65a3 (patch)
tree6b4606b06088f9b55b313857f78be5dcd718481c /test/integration/targets
parentvars/varnames more examles more varied (#84300) (diff)
downloadansible-e14f9fe725e1fb1cf37a0aac932d9b9c1f1c65a3.tar.xz
ansible-e14f9fe725e1fb1cf37a0aac932d9b9c1f1c65a3.zip
Sequence query fix (#83758)
Co-authored-by: flowerysong <junk+github@flowerysong.com>
Diffstat (limited to '')
-rw-r--r--test/integration/targets/lookup_sequence/tasks/main.yml29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/integration/targets/lookup_sequence/tasks/main.yml b/test/integration/targets/lookup_sequence/tasks/main.yml
index 3d74339e8c..e640d42b4c 100644
--- a/test/integration/targets/lookup_sequence/tasks/main.yml
+++ b/test/integration/targets/lookup_sequence/tasks/main.yml
@@ -196,3 +196,32 @@
- ansible_failed_result.msg == expected
vars:
expected: "bad formatting string: d"
+
+# Tests for lookup()/plugin() jinja invocation:
+# Many of these tests check edge case behaviors that are only possible when invoking query/lookup sequence through jinja.
+# While they aren't particularly intuitive, these tests ensure playbooks that could be relying on these behaviors don't
+# break in future
+- name: Test lookup with keyword args only
+ assert:
+ that:
+ - query("ansible.builtin.sequence", count=5, start=10) == ["10", "11", "12", "13", "14"]
+
+- name: Test that multiple positional args produces concatenated sequence
+ assert:
+ that:
+ - query("ansible.builtin.sequence", "count=5 start=1", "count=3 start=10 stride=2") == ["1", "2", "3", "4", "5", "10", "12", "14"]
+
+- name: Test that keyword arguments are applied to all positional expressions
+ assert:
+ that:
+ - query("ansible.builtin.sequence", "count=5 start=0", "count=5 start=20", stride=2) == ["0", "2", "4", "6", "8", "20", "22", "24", "26", "28"]
+
+- name: Test that keyword arguments do not overwrite parameters present in positional expressions
+ assert:
+ that:
+ - query("ansible.builtin.sequence", "count=5 start=0", "count=5", start=20) == ["0", "1", "2", "3", "4", "20", "21", "22", "23", "24"]
+
+- name: Test that call with no arguments produces an empty list
+ assert:
+ that:
+ - query("ansible.builtin.sequence") == []