let :default_params do
{
+ :ensure => 'present',
+ :order => '',
:packages => '*',
- :priority => '0'
+ :priority => '0',
+ :release => nil
}
end
- [{},
- {
+ [ {},
+ {
:packages => 'apache',
:priority => '1'
+ },
+ {
+ :order => 50,
+ :packages => 'apache',
+ :priority => '1'
+ },
+ {
+ :ensure => 'absent',
+ :packages => 'apache',
+ :priority => '1'
+ },
+ {
+ :packages => 'apache',
+ :priority => '1',
+ :release => 'my_newpin'
}
].each do |param_set|
describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do
it { should include_class("apt::params") }
it { should contain_file("#{title}.pref").with({
- 'path' => "/etc/apt/preferences.d/#{title}",
- 'ensure' => "file",
- 'owner' => "root",
- 'group' => "root",
- 'mode' => "644",
- 'content' => "# #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{title}\nPin-Priority: #{param_hash[:priority]}"
+ 'ensure' => param_hash[:ensure],
+ 'path' => "/etc/apt/preferences.d/#{param_hash[:order] == '' ? "" : "#{param_hash[:order]}-"}#{title}.pref",
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => '0644',
+ 'content' => "# #{title}\nExplanation: : #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{param_hash[:release] || title}\nPin-Priority: #{param_hash[:priority]}\n",
})
}
end