Use anchor to require necessary packages
... so that correct packages are required without re-defining them in resource implementations. Change-Id: Icaae881f5d074ad388eaddd26eb82261ea78937d
This commit is contained in:
parent
f6563cb4de
commit
f1e98f1585
@ -45,8 +45,8 @@ Puppet::Type.newtype(:ceilometer_api_paste_ini) do
|
||||
defaultto('<SERVICE DEFAULT>')
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'ceilometer'
|
||||
autorequire(:anchor) do
|
||||
['ceilometer::install::end']
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -57,8 +57,8 @@ Puppet::Type.newtype(:ceilometer_config) do
|
||||
defaultto('<SERVICE DEFAULT>')
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'ceilometer-common'
|
||||
autorequire(:anchor) do
|
||||
['ceilometer::install::end']
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -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/ceilometer_api_paste_ini'
|
||||
|
||||
describe 'Puppet::Type.type(:ceilometer_api_paste_ini)' do
|
||||
before :each do
|
||||
@ceilometer_api_paste_ini = Puppet::Type.type(:ceilometer_api_paste_ini).new(:name => 'DEFAULT/foo', :value => 'bar')
|
||||
end
|
||||
|
||||
it 'should accept a valid value' do
|
||||
@ceilometer_api_paste_ini[:value] = 'bar'
|
||||
expect(@ceilometer_api_paste_ini[:value]).to eq('bar')
|
||||
@ -23,12 +13,12 @@ describe 'Puppet::Type.type(:ceilometer_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 => 'ceilometer')
|
||||
catalog.add_resource package, @ceilometer_api_paste_ini
|
||||
anchor = Puppet::Type.type(:anchor).new(:name => 'ceilometer::install::end')
|
||||
catalog.add_resource anchor, @ceilometer_api_paste_ini
|
||||
dependency = @ceilometer_api_paste_ini.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@ceilometer_api_paste_ini)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
expect(dependency[0].source).to eq(anchor)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -51,14 +51,14 @@ describe 'Puppet::Type.type(:ceilometer_config)' do
|
||||
}.to raise_error(Puppet::Error, /Invalid value/)
|
||||
end
|
||||
|
||||
it 'should autorequire the package that install the file' do
|
||||
it 'should autorequire the pachage that install the file' do
|
||||
catalog = Puppet::Resource::Catalog.new
|
||||
package = Puppet::Type.type(:package).new(:name => 'ceilometer-common')
|
||||
catalog.add_resource package, @ceilometer_config
|
||||
anchor = Puppet::Type.type(:anchor).new(:name => 'ceilometer::install::end')
|
||||
catalog.add_resource anchor, @ceilometer_config
|
||||
dependency = @ceilometer_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@ceilometer_config)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
expect(dependency[0].source).to eq(anchor)
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user