2012-01-23 22:08:00 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
describe 'apt::pin', :type => :define do
|
2015-02-18 20:43:50 +01:00
|
|
|
let :pre_condition do
|
|
|
|
'class { "apt": }'
|
|
|
|
end
|
2015-05-07 00:10:05 +02:00
|
|
|
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } }
|
2012-01-23 22:08:00 +01:00
|
|
|
let(:title) { 'my_pin' }
|
|
|
|
|
2014-08-01 00:11:57 +02:00
|
|
|
context 'defaults' do
|
2015-02-24 23:57:31 +01:00
|
|
|
it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n/)}
|
2015-02-26 19:12:53 +01:00
|
|
|
it { is_expected.to contain_apt__setting("pref-my_pin") }
|
2012-01-23 22:08:00 +01:00
|
|
|
end
|
|
|
|
|
2014-08-01 00:11:57 +02:00
|
|
|
context 'set version' do
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
'packages' => 'vim',
|
|
|
|
'version' => '1',
|
|
|
|
}
|
|
|
|
end
|
2015-02-24 23:57:31 +01:00
|
|
|
it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n/)}
|
2015-02-26 19:12:53 +01:00
|
|
|
it { is_expected.to contain_apt__setting("pref-my_pin") }
|
2014-08-01 00:11:57 +02:00
|
|
|
end
|
2012-01-23 22:08:00 +01:00
|
|
|
|
2014-08-01 00:11:57 +02:00
|
|
|
context 'set origin' do
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
'packages' => 'vim',
|
|
|
|
'origin' => 'test',
|
|
|
|
}
|
|
|
|
end
|
2015-02-24 23:57:31 +01:00
|
|
|
it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n/)}
|
2015-02-26 19:12:53 +01:00
|
|
|
it { is_expected.to contain_apt__setting("pref-my_pin") }
|
2014-08-01 00:11:57 +02:00
|
|
|
end
|
2012-01-23 22:08:00 +01:00
|
|
|
|
2014-08-01 00:11:57 +02:00
|
|
|
context 'not defaults' do
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
'explanation' => 'foo',
|
|
|
|
'order' => 99,
|
|
|
|
'release' => '1',
|
|
|
|
'codename' => 'bar',
|
|
|
|
'release_version' => '2',
|
|
|
|
'component' => 'baz',
|
|
|
|
'originator' => 'foobar',
|
|
|
|
'label' => 'foobaz',
|
|
|
|
'priority' => 10,
|
|
|
|
}
|
|
|
|
end
|
2015-02-24 23:57:31 +01:00
|
|
|
it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n/) }
|
|
|
|
it { is_expected.to contain_apt__setting("pref-my_pin").with({
|
|
|
|
'priority' => 99,
|
2014-08-01 00:11:57 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
end
|
2012-01-23 22:08:00 +01:00
|
|
|
|
2014-08-01 00:11:57 +02:00
|
|
|
context 'ensure absent' do
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
'ensure' => 'absent'
|
2012-01-23 22:08:00 +01:00
|
|
|
}
|
|
|
|
end
|
2015-02-24 23:57:31 +01:00
|
|
|
it { is_expected.to contain_apt__setting("pref-my_pin").with({
|
2014-08-01 00:11:57 +02:00
|
|
|
'ensure' => 'absent',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'bad characters' do
|
|
|
|
let(:title) { 'such bad && wow!' }
|
2015-02-24 23:57:31 +01:00
|
|
|
it { is_expected.to contain_apt__setting("pref-such__bad____wow_") }
|
2012-01-23 22:08:00 +01:00
|
|
|
end
|
2014-03-05 16:12:04 +01:00
|
|
|
|
2014-08-01 00:11:57 +02:00
|
|
|
describe 'validation' do
|
|
|
|
context 'invalid order' do
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
'order' => 'foo',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
it do
|
|
|
|
expect {
|
2015-04-23 01:31:47 +02:00
|
|
|
subject.call
|
2014-08-01 00:11:57 +02:00
|
|
|
}.to raise_error(Puppet::Error, /Only integers are allowed/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'packages == * and version' do
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
'version' => '1',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
it do
|
|
|
|
expect {
|
2015-04-23 01:31:47 +02:00
|
|
|
subject.call
|
2014-08-01 00:11:57 +02:00
|
|
|
}.to raise_error(Puppet::Error, /parameter version cannot be used in general form/)
|
|
|
|
end
|
2014-03-05 16:12:04 +01:00
|
|
|
end
|
|
|
|
|
2014-08-01 00:11:57 +02:00
|
|
|
context 'packages == * and release and origin' do
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
'origin' => 'test',
|
|
|
|
'release' => 'foo',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
it do
|
|
|
|
expect {
|
2015-04-23 01:31:47 +02:00
|
|
|
subject.call
|
2014-08-01 00:11:57 +02:00
|
|
|
}.to raise_error(Puppet::Error, /parameters release and origin are mutually exclusive/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'specific form with release and origin' do
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
'release' => 'foo',
|
|
|
|
'origin' => 'test',
|
|
|
|
'packages' => 'vim',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
it do
|
|
|
|
expect {
|
2015-04-23 01:31:47 +02:00
|
|
|
subject.call
|
2014-08-01 00:11:57 +02:00
|
|
|
}.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'specific form with version and origin' do
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
'version' => '1',
|
|
|
|
'origin' => 'test',
|
|
|
|
'packages' => 'vim',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
it do
|
|
|
|
expect {
|
2015-04-23 01:31:47 +02:00
|
|
|
subject.call
|
2014-08-01 00:11:57 +02:00
|
|
|
}.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
|
|
|
|
end
|
2014-03-05 16:12:04 +01:00
|
|
|
end
|
|
|
|
end
|
2012-01-23 22:08:00 +01:00
|
|
|
end
|