Add multistropt test cases

Incorporate the musltistropt test cases from openstack-ansible-plugins
/tests/test-config_template.yml excluded from ansible-config_template

Change-Id: I57c4eb3e1c879671facfa4564f78869961a4e9f2
Closes-Bug: #1815620
This commit is contained in:
Sam Choraria 2019-02-13 11:35:44 +00:00 committed by Kevin Carter (cloudnull)
parent 78bcedc36e
commit 869f3127ed
3 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,7 @@
[multistropts]
test = test1
test = test2
test = test3
[testsection]
test = output

View File

@ -0,0 +1,5 @@
[multistropts]
test = test1
test = test2
test = test3

View File

@ -128,6 +128,42 @@
that:
- "((hostvars_file.content | b64decode | from_yaml).test_hostvar) == (test_config_yml_hostvars_overrides.test_hostvar)"
# Test multistropt ordering
- name: Template MultiStrOpts using overrides
config_template:
src: test_multistropts.ini
dest: /tmp/test_multistropts.ini
config_overrides:
testsection:
test: output
config_type: ini
- name: Create expected MultiStrOpts file
copy:
src: files/test_multistropts.ini.expected
dest: /tmp/test_multistropts.ini.expected
- name: Read test_multistropts.ini
slurp:
src: /tmp/test_multistropts.ini
register: multistropts_file
- name: Read test_multistropts.ini.expected
slurp:
src: /tmp/test_multistropts.ini.expected
register: multistropts_expected_file
- name: Set content facts
set_fact:
_multistropts_file: "{{ (multistropts_file.content | b64decode).strip() }}"
_multistropts_expected_file: "{{ (multistropts_expected_file.content | b64decode).strip() }}"
- name: Show rendered file
debug:
msg: "multistropts rendered - {{ _multistropts_file }}"
- name: Show expected file
debug:
msg: "multistropts expected - {{ _multistropts_expected_file }}"
- name: Compare files
assert:
that:
- _multistropts_file == _multistropts_expected_file
# Test content attribute with a dictionary input and config_type equal to 'json'
- name: Template test JSON template with content attribute