Merge "Use anchor to require necessary packages"

This commit is contained in:
Zuul 2020-05-04 01:44:18 +00:00 committed by Gerrit Code Review
commit ae4c33dd81
4 changed files with 13 additions and 23 deletions

View File

@ -45,8 +45,8 @@ Puppet::Type.newtype(:heat_api_paste_ini) do
defaultto('<SERVICE DEFAULT>')
end
autorequire(:package) do
'heat-common'
autorequire(:anchor) do
['heat::install::end']
end
end

View File

@ -46,8 +46,8 @@ Puppet::Type.newtype(:heat_config) do
defaultto('<SERVICE DEFAULT>')
end
autorequire(:package) do
'heat-common'
autorequire(:anchor) do
['heat::install::end']
end
end

View File

@ -1,21 +1,11 @@
require 'spec_helper'
# this hack is required for now to ensure that the path is set up correctly
# to retrieve the parent provider
$LOAD_PATH.push(
File.join(
File.dirname(__FILE__),
'..',
'..',
'fixtures',
'modules',
'inifile',
'lib')
)
require 'puppet'
require 'puppet/type/heat_api_paste_ini'
describe 'Puppet::Type.type(:heat_api_paste_ini)' do
before :each do
@heat_api_paste_ini = Puppet::Type.type(:heat_api_paste_ini).new(:name => 'DEFAULT/foo', :value => 'bar')
end
it 'should accept a valid value' do
@heat_api_paste_ini[:value] = 'bar'
expect(@heat_api_paste_ini[:value]).to eq('bar')
@ -23,12 +13,12 @@ describe 'Puppet::Type.type(:heat_api_paste_ini)' do
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'heat-common')
catalog.add_resource package, @heat_api_paste_ini
anchor = Puppet::Type.type(:anchor).new(:name => 'heat::install::end')
catalog.add_resource anchor, @heat_api_paste_ini
dependency = @heat_api_paste_ini.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@heat_api_paste_ini)
expect(dependency[0].source).to eq(package)
expect(dependency[0].source).to eq(anchor)
end
end

View File

@ -54,12 +54,12 @@ describe 'Puppet::Type.type(:heat_config)' do
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'heat-common')
catalog.add_resource package, @heat_config
anchor = Puppet::Type.type(:anchor).new(:name => 'heat::install::end')
catalog.add_resource anchor, @heat_config
dependency = @heat_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@heat_config)
expect(dependency[0].source).to eq(package)
expect(dependency[0].source).to eq(anchor)
end
end