Merge "Use anchor to require necessary packages"

This commit is contained in:
Zuul 2020-05-04 01:37:50 +00:00 committed by Gerrit Code Review
commit b450f8894c
2 changed files with 13 additions and 2 deletions

View File

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

View File

@ -49,4 +49,15 @@ describe 'Puppet::Type.type(:zaqar_config)' do
@zaqar_config[:ensure] = :latest
}.to raise_error(Puppet::Error, /Invalid value/)
end
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
anchor = Puppet::Type.type(:anchor).new(:name => 'zaqar::install::end')
catalog.add_resource anchor, @zaqar_config
dependency = @zaqar_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@zaqar_config)
expect(dependency[0].source).to eq(anchor)
end
end