Browse Source

Use anchor to require necessary packages

... so that correct packages are required without re-defining them in
resource implementations.

Change-Id: Ib00bf9593a3ea05a70538758e268b85b0b8dbc3f
changes/82/725182/1
Takashi Kajinami 1 year ago
parent
commit
38b523a542
2 changed files with 6 additions and 6 deletions
  1. +2
    -2
      lib/puppet/type/watcher_config.rb
  2. +4
    -4
      spec/unit/type/watcher_config_spec.rb

+ 2
- 2
lib/puppet/type/watcher_config.rb View File

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

+ 4
- 4
spec/unit/type/watcher_config_spec.rb View File

@ -1,5 +1,6 @@
require 'puppet'
require 'puppet/type/watcher_config'
describe 'Puppet::Type.type(:watcher_config)' do
before :each do
@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
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'watcher')
catalog.add_resource package, @watcher_config
anchor = Puppet::Type.type(:anchor).new(:name => 'watcher::install::end')
catalog.add_resource anchor, @watcher_config
dependency = @watcher_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@watcher_config)
expect(dependency[0].source).to eq(package)
expect(dependency[0].source).to eq(anchor)
end
end

Loading…
Cancel
Save