Debian Codegraph @

test/integration/targets/lookup_ini/test_errors.yml

raw
1 - name: Test INI lookup errors
2 hosts: testhost
3
4 tasks:
5 - name: Lookup a file with duplicate keys
6 debug:
7 msg: "{{ lookup('ini', 'name', file='duplicate.ini', section='reggae') }}"
8 ignore_errors: yes
9 register: duplicate
10
11 - name: Lookup a file with keys that differ only in case
12 debug:
13 msg: "{{ lookup('ini', 'name', file='duplicate_case_check.ini', section='reggae') }}"
14 ignore_errors: yes
15 register: duplicate_case_sensitive
16
17 - name: Ensure duplicate key errors were handled properly
18 assert:
19 that:
20 - duplicate is failed
21 - "'Duplicate option in' in duplicate.msg"
22 - duplicate_case_sensitive is failed
23 - "'Duplicate option in' in duplicate_case_sensitive.msg"
24
25 - name: Lookup a file with a missing section
26 debug:
27 msg: "{{ lookup('ini', 'name', file='lookup.ini', section='missing') }}"
28 ignore_errors: yes
29 register: missing_section
30
31 - name: Ensure error was shown for a missing section
32 assert:
33 that:
34 - missing_section is failed
35 - "'No section' in missing_section.msg"
36
37 - name: Mix options type and push key out of order
38 debug:
39 msg: "{{ lookup('ini', 'file=lookup.ini', 'value1', section='value_section') }}"
40 register: bad_mojo
41 ignore_errors: yes
42
43 - name: Verify bad behavior reported an error
44 assert:
45 that:
46 - bad_mojo is failed
47 - '"No key to look up was provided as first term within string inline options" in bad_mojo.msg'
48
49 - name: Test invalid option
50 debug:
51 msg: "{{ lookup('ini', 'invalid=option') }}"
52 ignore_errors: yes
53 register: invalid_option
54
55 - name: Ensure invalid option failed
56 assert:
57 that:
58 - invalid_option is failed
59 - "'is not a valid option' in invalid_option.msg"