Merge "Convert spec testing to rspec-puppet-facts"

This commit is contained in:
Zuul 2018-11-12 05:59:48 +00:00 committed by Gerrit Code Review
commit 95b720f7dc
2 changed files with 49 additions and 22 deletions

View File

@ -3,7 +3,8 @@ require 'spec_helper'
describe 'heat::config' do describe 'heat::config' do
let :params do let :params do
{ :heat_config => { {
:heat_config => {
'DEFAULT/foo' => { 'value' => 'fooValue' }, 'DEFAULT/foo' => { 'value' => 'fooValue' },
'DEFAULT/bar' => { 'value' => 'barValue' }, 'DEFAULT/bar' => { 'value' => 'barValue' },
'DEFAULT/baz' => { 'ensure' => 'absent' } 'DEFAULT/baz' => { 'ensure' => 'absent' }
@ -16,18 +17,31 @@ describe 'heat::config' do
} }
end end
it { is_expected.to contain_class('heat::deps') } shared_examples 'heat::config' do
it { should contain_class('heat::deps') }
it 'configures arbitrary heat configurations' do it {
is_expected.to contain_heat_config('DEFAULT/foo').with_value('fooValue') should contain_heat_config('DEFAULT/foo').with_value('fooValue')
is_expected.to contain_heat_config('DEFAULT/bar').with_value('barValue') should contain_heat_config('DEFAULT/bar').with_value('barValue')
is_expected.to contain_heat_config('DEFAULT/baz').with_ensure('absent') should contain_heat_config('DEFAULT/baz').with_ensure('absent')
}
it {
should contain_heat_api_paste_ini('DEFAULT/foo2').with_value('fooValue')
should contain_heat_api_paste_ini('DEFAULT/bar2').with_value('barValue')
should contain_heat_api_paste_ini('DEFAULT/baz2').with_ensure('absent')
}
end end
it 'configures arbitrary heat-api-paste configurations' do on_supported_os({
is_expected.to contain_heat_api_paste_ini('DEFAULT/foo2').with_value('fooValue') :supported_os => OSDefaults.get_supported_os
is_expected.to contain_heat_api_paste_ini('DEFAULT/bar2').with_value('barValue') }).each do |os,facts|
is_expected.to contain_heat_api_paste_ini('DEFAULT/baz2').with_ensure('absent') context "on #{os}" do
end let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'heat::config'
end
end
end end

View File

@ -1,17 +1,30 @@
require 'spec_helper' require 'spec_helper'
describe 'heat::deps' do describe 'heat::deps' do
shared_examples 'heat::deps' do
it {
should contain_anchor('heat::install::begin')
should contain_anchor('heat::install::end')
should contain_anchor('heat::config::begin')
should contain_anchor('heat::config::end')
should contain_anchor('heat::db::begin')
should contain_anchor('heat::db::end')
should contain_anchor('heat::dbsync::begin')
should contain_anchor('heat::dbsync::end')
should contain_anchor('heat::service::begin')
should contain_anchor('heat::service::end')
}
end
it 'set up the anchors' do on_supported_os({
is_expected.to contain_anchor('heat::install::begin') :supported_os => OSDefaults.get_supported_os
is_expected.to contain_anchor('heat::install::end') }).each do |os,facts|
is_expected.to contain_anchor('heat::config::begin') context "on #{os}" do
is_expected.to contain_anchor('heat::config::end') let (:facts) do
is_expected.to contain_anchor('heat::db::begin') facts.merge!(OSDefaults.get_facts())
is_expected.to contain_anchor('heat::db::end') end
is_expected.to contain_anchor('heat::dbsync::begin')
is_expected.to contain_anchor('heat::dbsync::end') it_behaves_like 'heat::deps'
is_expected.to contain_anchor('heat::service::begin') end
is_expected.to contain_anchor('heat::service::end')
end end
end end