Use anchor to require necessary packages
... so that correct packages are required without re-defining them in resource implementations. Change-Id: Ib00bf9593a3ea05a70538758e268b85b0b8dbc3f
This commit is contained in:
parent
66f1eb0822
commit
38b523a542
@ -46,8 +46,8 @@ Puppet::Type.newtype(:watcher_config) do
|
|||||||
defaultto('<SERVICE DEFAULT>')
|
defaultto('<SERVICE DEFAULT>')
|
||||||
end
|
end
|
||||||
|
|
||||||
autorequire(:package) do
|
autorequire(:anchor) do
|
||||||
'watcher'
|
['watcher::install::end']
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
require 'puppet'
|
require 'puppet'
|
||||||
require 'puppet/type/watcher_config'
|
require 'puppet/type/watcher_config'
|
||||||
|
|
||||||
describe 'Puppet::Type.type(:watcher_config)' do
|
describe 'Puppet::Type.type(:watcher_config)' do
|
||||||
before :each do
|
before :each do
|
||||||
@watcher_config = Puppet::Type.type(:watcher_config).new(:name => 'DEFAULT/foo', :value => 'bar')
|
@watcher_config = Puppet::Type.type(:watcher_config).new(:name => 'DEFAULT/foo', :value => 'bar')
|
||||||
@ -52,13 +53,12 @@ describe 'Puppet::Type.type(:watcher_config)' do
|
|||||||
|
|
||||||
it 'should autorequire the package that install the file' do
|
it 'should autorequire the package that install the file' do
|
||||||
catalog = Puppet::Resource::Catalog.new
|
catalog = Puppet::Resource::Catalog.new
|
||||||
package = Puppet::Type.type(:package).new(:name => 'watcher')
|
anchor = Puppet::Type.type(:anchor).new(:name => 'watcher::install::end')
|
||||||
catalog.add_resource package, @watcher_config
|
catalog.add_resource anchor, @watcher_config
|
||||||
dependency = @watcher_config.autorequire
|
dependency = @watcher_config.autorequire
|
||||||
expect(dependency.size).to eq(1)
|
expect(dependency.size).to eq(1)
|
||||||
expect(dependency[0].target).to eq(@watcher_config)
|
expect(dependency[0].target).to eq(@watcher_config)
|
||||||
expect(dependency[0].source).to eq(package)
|
expect(dependency[0].source).to eq(anchor)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user