summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/lookup_csvfile
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2021-04-13 21:52:42 +0200
committerGitHub <noreply@github.com>2021-04-13 21:52:42 +0200
commit84e473a26ea95afec207409c42ba872c009fe6b6 (patch)
treeb64d3bbf9384c3134c97a06c658ec7062cefada2 /test/integration/targets/lookup_csvfile
parentBump azure-pipelines-test-container to version 1.9.0 (diff)
downloadansible-84e473a26ea95afec207409c42ba872c009fe6b6.tar.xz
ansible-84e473a26ea95afec207409c42ba872c009fe6b6.zip
All lookups ported to config system (#74108)
* all lookups to support config system - added get_options to get full dict with all opts - fixed tests to match new error messages - kept inline string k=v parsing methods for backwards compat - placeholder depredation for inline string k=v parsing - updated tests and examples to also show new way - refactored and added comments to most custom k=v parsing - added missing docs for template_vars to template - normalized error messages and exception types - fixed constants default - better details value errors Co-authored-by: Felix Fontein <felix@fontein.de>
Diffstat (limited to 'test/integration/targets/lookup_csvfile')
-rw-r--r--test/integration/targets/lookup_csvfile/tasks/main.yml30
1 files changed, 22 insertions, 8 deletions
diff --git a/test/integration/targets/lookup_csvfile/tasks/main.yml b/test/integration/targets/lookup_csvfile/tasks/main.yml
index 14b79bd674..758da71e87 100644
--- a/test/integration/targets/lookup_csvfile/tasks/main.yml
+++ b/test/integration/targets/lookup_csvfile/tasks/main.yml
@@ -1,15 +1,23 @@
-- set_fact:
- this_will_error: "{{ lookup('csvfile', 'file=people.csv delimiter=, col=1') }}"
+- name: using deprecated syntax but missing keyword
+ set_fact:
+ this_will_error: "{{ lookup('csvfile', 'file=people.csv, delimiter=, col=1') }}"
ignore_errors: yes
register: no_keyword
-- set_fact:
+- name: extra arg in k=v syntax (deprecated)
+ set_fact:
this_will_error: "{{ lookup('csvfile', 'foo file=people.csv delimiter=, col=1 thisarg=doesnotexist') }}"
ignore_errors: yes
register: invalid_arg
+- name: extra arg in config syntax
+ set_fact:
+ this_will_error: "{{ lookup('csvfile', 'foo', file='people.csv', delimiter=',' col=1, thisarg='doesnotexist') }}"
+ ignore_errors: yes
+ register: invalid_arg2
+
- set_fact:
- this_will_error: "{{ lookup('csvfile', 'foo file=doesnotexist delimiter=, col=1') }}"
+ this_will_error: "{{ lookup('csvfile', 'foo', file='doesnotexist', delimiter=',', col=1) }}"
ignore_errors: yes
register: missing_file
@@ -19,24 +27,30 @@
- no_keyword is failed
- >
"Search key is required but was not found" in no_keyword.msg
+ - invalid_arg is failed
+ - invalid_arg2 is failed
- >
- "not in paramvals" in invalid_arg.msg
+ "is not a valid option" in invalid_arg.msg
- missing_file is failed
- >
- "need string or buffer" in missing_file.msg or "expected str, bytes or os.PathLike object" in missing_file.msg
+ "need string or buffer" in missing_file.msg or
+ "expected str, bytes or os.PathLike object" in missing_file.msg or
+ "No such file or directory" in missing_file.msg
- name: Check basic comma-separated file
assert:
that:
- - lookup('csvfile', 'Smith file=people.csv delimiter=, col=1') == "Jane"
+ - lookup('csvfile', 'Smith', file='people.csv', delimiter=',', col=1) == "Jane"
- lookup('csvfile', 'German von Lastname file=people.csv delimiter=, col=1') == "Demo"
- name: Check tab-separated file
assert:
that:
- lookup('csvfile', 'electronics file=tabs.csv delimiter=TAB col=1') == "tvs"
- - lookup('csvfile', 'fruit file=tabs.csv delimiter=TAB col=1') == "bananas"
+ - "lookup('csvfile', 'fruit', file='tabs.csv', delimiter='TAB', col=1) == 'bananas'"
- lookup('csvfile', 'fruit file=tabs.csv delimiter="\t" col=1') == "bananas"
+ - lookup('csvfile', 'electronics', 'fruit', file='tabs.csv', delimiter='\t', col=1) == "tvs,bananas"
+ - lookup('csvfile', 'electronics', 'fruit', file='tabs.csv', delimiter='\t', col=1, wantlist=True) == ["tvs", "bananas"]
- name: Check \x1a-separated file
assert: