From 413a0cafefb356c20cd656cb992ee2481944b335 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 1 Jul 2021 17:58:08 +0900 Subject: [PATCH] Do not test detail of oslo::cors This change makes unit test cases for mistral::cors, so that these tests do not test behavir of oslo::cors but how oslo::cors resource type is called by mistral::cors. Change-Id: I25afe42205ede6d836625505315da8bd50207a1f --- spec/classes/mistral_cors_spec.rb | 32 +++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/spec/classes/mistral_cors_spec.rb b/spec/classes/mistral_cors_spec.rb index 247c34d..50ea23d 100644 --- a/spec/classes/mistral_cors_spec.rb +++ b/spec/classes/mistral_cors_spec.rb @@ -2,14 +2,16 @@ require 'spec_helper' describe 'mistral::cors' do - shared_examples_for 'mistral cors' do + shared_examples_for 'mistral::cors' do it 'configure cors default params' do - is_expected.to contain_mistral_config('cors/allowed_origin').with_value('') - is_expected.to contain_mistral_config('cors/allow_credentials').with_value('') - is_expected.to contain_mistral_config('cors/expose_headers').with_value('') - is_expected.to contain_mistral_config('cors/max_age').with_value('') - is_expected.to contain_mistral_config('cors/allow_methods').with_value('') - is_expected.to contain_mistral_config('cors/allow_headers').with_value('') + is_expected.to contain_oslo__cors('mistral_config').with( + :allowed_origin => '', + :allow_credentials => '', + :expose_headers => '', + :max_age => '', + :allow_methods => '', + :allow_headers => '', + ) end context 'with specific parameters' do @@ -24,12 +26,14 @@ describe 'mistral::cors' do end it 'configure cors params' do - is_expected.to contain_mistral_config('cors/allowed_origin').with_value('*') - is_expected.to contain_mistral_config('cors/allow_credentials').with_value(true) - is_expected.to contain_mistral_config('cors/expose_headers').with_value('Content-Language,Expires') - is_expected.to contain_mistral_config('cors/max_age').with_value(3600) - is_expected.to contain_mistral_config('cors/allow_methods').with_value('GET,POST,PUT,DELETE,OPTIONS') - is_expected.to contain_mistral_config('cors/allow_headers').with_value('Content-Type,Cache-Control') + is_expected.to contain_oslo__cors('mistral_config').with( + :allowed_origin => '*', + :allow_credentials => true, + :expose_headers => 'Content-Language,Expires', + :max_age => 3600, + :allow_methods => 'GET,POST,PUT,DELETE,OPTIONS', + :allow_headers => 'Content-Type,Cache-Control', + ) end end end @@ -42,7 +46,7 @@ describe 'mistral::cors' do facts.merge!(OSDefaults.get_facts()) end - it_configures 'mistral cors' + it_behaves_like 'mistral::cors' end end