summaryrefslogtreecommitdiff
path: root/test/integration/targets
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2020-02-27 21:43:40 -0800
committerMatt Clay <matt@mystile.com>2020-02-28 08:38:50 -0800
commitb84dc2f2a681aec8fca974573118a2b470083179 (patch)
tree90ed799fbe413780bbed4c9c0e05004c133573ab /test/integration/targets
parent9392912608f82ed2a38ab4abc6e3b4db0a61d637 (diff)
downloadansible-b84dc2f2a681aec8fca974573118a2b470083179.tar.gz
Add integration test for regex_search filter.
Diffstat (limited to 'test/integration/targets')
-rw-r--r--test/integration/targets/filter_core/tasks/main.yml26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/integration/targets/filter_core/tasks/main.yml b/test/integration/targets/filter_core/tasks/main.yml
index 9db278dde8..230b7b4f62 100644
--- a/test/integration/targets/filter_core/tasks/main.yml
+++ b/test/integration/targets/filter_core/tasks/main.yml
@@ -235,3 +235,29 @@
- assert:
that:
- "result.msg.startswith('The task includes an option with an undefined variable')"
+
+- name: regex_search
+ set_fact:
+ match_case: "{{ 'hello' | regex_search('HELLO', ignorecase=false) }}"
+ ignore_case: "{{ 'hello' | regex_search('HELLO', ignorecase=true) }}"
+ single_line: "{{ 'hello\nworld' | regex_search('^world', multiline=false) }}"
+ multi_line: "{{ 'hello\nworld' | regex_search('^world', multiline=true) }}"
+ named_groups: "{{ 'goodbye' | regex_search('(?P<first>good)(?P<second>bye)', '\\g<second>', '\\g<first>') }}"
+ numbered_groups: "{{ 'goodbye' | regex_search('(good)(bye)', '\\2', '\\1') }}"
+
+- name: regex_search unknown argument (failure expected)
+ set_fact:
+ unknown_arg: "{{ 'hello' | regex_search('hello', 'unknown') }}"
+ ignore_errors: yes
+ register: failure
+
+- name: regex_search check
+ assert:
+ that:
+ - match_case == ''
+ - ignore_case == 'hello'
+ - single_line == ''
+ - multi_line == 'world'
+ - named_groups == ['bye', 'good']
+ - numbered_groups == ['bye', 'good']
+ - failure is failed