2012-01-23 22:08:00 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
describe 'apt::pin', :type => :define do
|
|
|
|
let(:title) { 'my_pin' }
|
|
|
|
|
|
|
|
let :default_params do
|
|
|
|
{
|
2012-05-04 01:59:13 +02:00
|
|
|
:ensure => 'present',
|
2012-08-21 23:14:54 +02:00
|
|
|
:order => '',
|
2012-01-23 22:08:00 +01:00
|
|
|
:packages => '*',
|
2012-05-04 22:56:35 +02:00
|
|
|
:priority => '0',
|
|
|
|
:release => nil
|
2012-01-23 22:08:00 +01:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2012-05-04 01:59:13 +02:00
|
|
|
[ {},
|
|
|
|
{
|
|
|
|
:packages => 'apache',
|
|
|
|
:priority => '1'
|
|
|
|
},
|
2012-08-21 23:14:54 +02:00
|
|
|
{
|
|
|
|
:order => 50,
|
|
|
|
:packages => 'apache',
|
|
|
|
:priority => '1'
|
|
|
|
},
|
2012-05-04 01:59:13 +02:00
|
|
|
{
|
|
|
|
:ensure => 'absent',
|
2012-01-23 22:08:00 +01:00
|
|
|
:packages => 'apache',
|
|
|
|
:priority => '1'
|
2012-05-04 22:56:35 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
:packages => 'apache',
|
|
|
|
:priority => '1',
|
|
|
|
:release => 'my_newpin'
|
2012-01-23 22:08:00 +01:00
|
|
|
}
|
|
|
|
].each do |param_set|
|
|
|
|
describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do
|
|
|
|
let :param_hash do
|
2012-02-04 02:24:09 +01:00
|
|
|
default_params.merge(param_set)
|
2012-01-23 22:08:00 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
let :params do
|
|
|
|
param_set
|
|
|
|
end
|
|
|
|
|
|
|
|
it { should include_class("apt::params") }
|
|
|
|
|
2012-02-04 02:24:09 +01:00
|
|
|
it { should contain_file("#{title}.pref").with({
|
2012-05-04 01:59:13 +02:00
|
|
|
'ensure' => param_hash[:ensure],
|
2012-08-21 23:14:54 +02:00
|
|
|
'path' => "/etc/apt/preferences.d/#{param_hash[:order] == '' ? "" : "#{param_hash[:order]}-"}#{title}.pref",
|
2012-03-21 14:20:13 +01:00
|
|
|
'owner' => 'root',
|
|
|
|
'group' => 'root',
|
|
|
|
'mode' => '0644',
|
2012-08-22 10:22:21 +02:00
|
|
|
'content' => "# #{title}\nExplanation: : #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{param_hash[:release] || title}\nPin-Priority: #{param_hash[:priority]}\n",
|
2012-02-04 02:24:09 +01:00
|
|
|
})
|
2012-01-23 22:08:00 +01:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|