Merge "Use anchor to require necessary packages"

This commit is contained in:
Zuul 2020-05-04 01:19:53 +00:00 committed by Gerrit Code Review
commit aa25a98382
4 changed files with 14 additions and 23 deletions

View File

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

View File

@ -44,8 +44,8 @@ Puppet::Type.newtype(:aodh_config) do
defaultto('<SERVICE DEFAULT>')
end
autorequire(:package) do
'aodh'
autorequire(:anchor) do
['aodh::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/aodh_api_paste_ini'
describe 'Puppet::Type.type(:aodh_api_paste_ini)' do
before :each do
@aodh_api_paste_ini = Puppet::Type.type(:aodh_api_paste_ini).new(:name => 'DEFAULT/foo', :value => 'bar')
end
it 'should accept a valid value' do
@aodh_api_paste_ini[:value] = 'bar'
expect(@aodh_api_paste_ini[:value]).to eq('bar')
@ -23,12 +13,12 @@ describe 'Puppet::Type.type(:aodh_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 => 'aodh-common')
catalog.add_resource package, @aodh_api_paste_ini
anchor = Puppet::Type.type(:anchor).new(:name => 'aodh::install::end')
catalog.add_resource anchor, @aodh_api_paste_ini
dependency = @aodh_api_paste_ini.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@aodh_api_paste_ini)
expect(dependency[0].source).to eq(package)
expect(dependency[0].source).to eq(anchor)
end
end

View File

@ -1,5 +1,6 @@
require 'puppet'
require 'puppet/type/aodh_config'
describe 'Puppet::Type.type(:aodh_config)' do
before :each do
@aodh_config = Puppet::Type.type(:aodh_config).new(:name => 'DEFAULT/foo', :value => 'bar')
@ -52,12 +53,12 @@ describe 'Puppet::Type.type(:aodh_config)' do
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'aodh')
catalog.add_resource package, @aodh_config
anchor = Puppet::Type.type(:anchor).new(:name => 'aodh::install::end')
catalog.add_resource anchor, @aodh_config
dependency = @aodh_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@aodh_config)
expect(dependency[0].source).to eq(package)
expect(dependency[0].source).to eq(anchor)
end
end