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
|
|
|
|
|
2013-06-18 11:31:38 +02:00
|
|
|
[
|
|
|
|
{ :params => {},
|
|
|
|
:content => "# my_pin\nExplanation: : my_pin\nPackage: *\nPin: release a=my_pin\nPin-Priority: 0\n"
|
|
|
|
},
|
2012-05-04 01:59:13 +02:00
|
|
|
{
|
2013-06-18 11:31:38 +02:00
|
|
|
:params => {
|
|
|
|
:packages => 'apache',
|
|
|
|
:priority => '1'
|
|
|
|
},
|
|
|
|
:content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n"
|
2012-05-04 01:59:13 +02:00
|
|
|
},
|
2012-08-21 23:14:54 +02:00
|
|
|
{
|
2013-06-18 11:31:38 +02:00
|
|
|
:params => {
|
|
|
|
:order => 50,
|
|
|
|
:packages => 'apache',
|
|
|
|
:priority => '1'
|
|
|
|
},
|
|
|
|
:content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n"
|
2012-08-21 23:14:54 +02:00
|
|
|
},
|
2012-05-04 01:59:13 +02:00
|
|
|
{
|
2013-06-18 11:31:38 +02:00
|
|
|
:params => {
|
|
|
|
:ensure => 'absent',
|
|
|
|
:packages => 'apache',
|
|
|
|
:priority => '1'
|
|
|
|
},
|
|
|
|
:content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n"
|
2012-05-04 22:56:35 +02:00
|
|
|
},
|
|
|
|
{
|
2013-06-18 11:31:38 +02:00
|
|
|
:params => {
|
|
|
|
:packages => 'apache',
|
|
|
|
:priority => '1',
|
|
|
|
:release => 'my_newpin'
|
|
|
|
},
|
|
|
|
:content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_newpin\nPin-Priority: 1\n"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
:params => {
|
|
|
|
:packages => 'apache',
|
|
|
|
:priority => '1',
|
|
|
|
:version => '2.2.16*'
|
|
|
|
},
|
|
|
|
:content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: version 2.2.16*\nPin-Priority: 1\n"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
:params => {
|
|
|
|
:priority => '1',
|
|
|
|
:origin => 'ftp.de.debian.org'
|
|
|
|
},
|
|
|
|
:content => "# my_pin\nExplanation: : my_pin\nPackage: *\nPin: origin \"ftp.de.debian.org\"\nPin-Priority: 1\n"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
:params => {
|
|
|
|
:packages => 'apache',
|
2014-02-14 16:13:14 +01:00
|
|
|
:priority => '1',
|
2013-06-18 11:31:38 +02:00
|
|
|
:release => 'stable',
|
|
|
|
:codename => 'wheezy',
|
|
|
|
:release_version => '3.0',
|
|
|
|
:component => 'main',
|
|
|
|
:originator => 'Debian',
|
|
|
|
:label => 'Debian'
|
|
|
|
},
|
|
|
|
:content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=stable, n=wheezy, v=3.0, c=main, o=Debian, l=Debian\nPin-Priority: 1\n"
|
|
|
|
},
|
2014-02-14 16:13:14 +01:00
|
|
|
{
|
|
|
|
:params => {
|
|
|
|
:packages => ['apache', 'ntop'],
|
|
|
|
},
|
|
|
|
:content => "# my_pin\nExplanation: : my_pin\nPackage: apache ntop\nPin: release a=my_pin\nPin-Priority: 0\n"
|
|
|
|
},
|
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
|
2013-06-18 11:31:38 +02:00
|
|
|
default_params.merge(param_set[:params])
|
2012-01-23 22:08:00 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
let :params do
|
2013-06-18 11:31:38 +02:00
|
|
|
param_set[:params]
|
2012-01-23 22:08:00 +01:00
|
|
|
end
|
|
|
|
|
2013-12-06 01:40:10 +01:00
|
|
|
it { should contain_class("apt::params") }
|
2012-01-23 22:08:00 +01:00
|
|
|
|
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',
|
2013-06-18 11:31:38 +02:00
|
|
|
'content' => param_set[:content],
|
2012-02-04 02:24:09 +01:00
|
|
|
})
|
2012-01-23 22:08:00 +01:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|