From 869f3127eda05732a004163d1606473632753c99 Mon Sep 17 00:00:00 2001 From: Sam Choraria Date: Wed, 13 Feb 2019 11:35:44 +0000 Subject: [PATCH] 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 --- tests/files/test_multistropts.ini.expected | 7 +++++ tests/templates/test_multistropts.ini | 5 +++ tests/test-common-tasks.yml | 36 ++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 tests/files/test_multistropts.ini.expected create mode 100644 tests/templates/test_multistropts.ini diff --git a/tests/files/test_multistropts.ini.expected b/tests/files/test_multistropts.ini.expected new file mode 100644 index 0000000..1847ea2 --- /dev/null +++ b/tests/files/test_multistropts.ini.expected @@ -0,0 +1,7 @@ +[multistropts] +test = test1 +test = test2 +test = test3 + +[testsection] +test = output diff --git a/tests/templates/test_multistropts.ini b/tests/templates/test_multistropts.ini new file mode 100644 index 0000000..ba2d61c --- /dev/null +++ b/tests/templates/test_multistropts.ini @@ -0,0 +1,5 @@ +[multistropts] +test = test1 +test = test2 +test = test3 + diff --git a/tests/test-common-tasks.yml b/tests/test-common-tasks.yml index 0d94a00..9964da5 100644 --- a/tests/test-common-tasks.yml +++ b/tests/test-common-tasks.yml @@ -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