2012-01-23 22:08:00 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
describe 'apt::pin', :type => :define do
|
2014-02-24 23:31:16 +01:00
|
|
|
let(:facts) { { :lsbdistid => 'Debian' } }
|
2012-01-23 22:08:00 +01:00
|
|
|
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
|
|
|
|
|
2014-02-24 23:31:16 +01:00
|
|
|
[
|
2013-06-18 11:31:38 +02:00
|
|
|
{ :params => {},
|
2014-03-28 08:47:19 +01:00
|
|
|
:content => "Explanation: : my_pin\nPackage: *\nPin: release a=my_pin\nPin-Priority: 0\n"
|
2013-06-18 11:31:38 +02:00
|
|
|
},
|
2012-05-04 01:59:13 +02:00
|
|
|
{
|
2013-06-18 11:31:38 +02:00
|
|
|
:params => {
|
2014-02-24 23:31:16 +01:00
|
|
|
:packages => 'apache',
|
2013-06-18 11:31:38 +02:00
|
|
|
:priority => '1'
|
|
|
|
},
|
2014-03-28 08:47:19 +01:00
|
|
|
:content => "Explanation: : 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 => {
|
2014-02-24 23:31:16 +01:00
|
|
|
:order => 50,
|
|
|
|
:packages => 'apache',
|
2013-06-18 11:31:38 +02:00
|
|
|
:priority => '1'
|
|
|
|
},
|
2014-03-28 08:47:19 +01:00
|
|
|
:content => "Explanation: : 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'
|
|
|
|
},
|
2014-03-28 08:47:19 +01:00
|
|
|
:content => "Explanation: : 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'
|
|
|
|
},
|
2014-03-28 08:47:19 +01:00
|
|
|
:content => "Explanation: : my_pin\nPackage: apache\nPin: release a=my_newpin\nPin-Priority: 1\n"
|
2013-06-18 11:31:38 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
:params => {
|
|
|
|
:packages => 'apache',
|
|
|
|
:priority => '1',
|
|
|
|
:version => '2.2.16*'
|
|
|
|
},
|
2014-03-28 08:47:19 +01:00
|
|
|
:content => "Explanation: : my_pin\nPackage: apache\nPin: version 2.2.16*\nPin-Priority: 1\n"
|
2013-06-18 11:31:38 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
:params => {
|
|
|
|
:priority => '1',
|
|
|
|
:origin => 'ftp.de.debian.org'
|
|
|
|
},
|
2014-03-28 08:47:19 +01:00
|
|
|
:content => "Explanation: : my_pin\nPackage: *\nPin: origin ftp.de.debian.org\nPin-Priority: 1\n"
|
2013-06-18 11:31:38 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
: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'
|
|
|
|
},
|
2014-03-28 08:47:19 +01:00
|
|
|
:content => "Explanation: : my_pin\nPackage: apache\nPin: release a=stable, n=wheezy, v=3.0, c=main, o=Debian, l=Debian\nPin-Priority: 1\n"
|
2013-06-18 11:31:38 +02:00
|
|
|
},
|
2014-02-14 16:13:14 +01:00
|
|
|
{
|
|
|
|
:params => {
|
|
|
|
:packages => ['apache', 'ntop'],
|
|
|
|
},
|
2014-03-28 08:47:19 +01:00
|
|
|
:content => "Explanation: : my_pin\nPackage: apache ntop\nPin: release a=my_pin\nPin-Priority: 0\n"
|
2014-02-14 16:13:14 +01:00
|
|
|
},
|
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
|
2014-03-05 16:12:04 +01:00
|
|
|
|
|
|
|
describe 'resource title with invalid chars' do
|
|
|
|
context 'spaces' do
|
|
|
|
let(:title) { 'oh my god this is not valid' }
|
|
|
|
it { should contain_file('oh_my_god_this_is_not_valid.pref') }
|
|
|
|
end
|
|
|
|
|
|
|
|
context '#$&*$' do
|
|
|
|
let(:title) { 'so && many $* invalid @! things' }
|
|
|
|
it { should contain_file('so____many____invalid____things.pref') }
|
|
|
|
end
|
|
|
|
end
|
2012-01-23 22:08:00 +01:00
|
|
|
end
|