2012-04-12 02:49:30 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
describe 'apt::conf', :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-04-12 02:49:30 +02:00
|
|
|
let :title do
|
|
|
|
'norecommends'
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "when creating an apt preference" do
|
2015-07-23 18:15:53 +02:00
|
|
|
let :default_params do
|
2012-04-12 02:49:30 +02:00
|
|
|
{
|
|
|
|
:priority => '00',
|
|
|
|
:content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n"
|
|
|
|
}
|
|
|
|
end
|
2015-07-23 18:15:53 +02:00
|
|
|
let :params do
|
|
|
|
default_params
|
|
|
|
end
|
2012-04-12 02:49:30 +02:00
|
|
|
|
|
|
|
let :filename do
|
|
|
|
"/etc/apt/apt.conf.d/00norecommends"
|
|
|
|
end
|
|
|
|
|
2015-02-24 22:20:29 +01:00
|
|
|
it { is_expected.to contain_file(filename).with({
|
2012-05-04 01:59:13 +02:00
|
|
|
'ensure' => 'present',
|
2014-08-31 15:46:57 +02:00
|
|
|
'content' => /Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;/,
|
2012-04-12 02:49:30 +02:00
|
|
|
'owner' => 'root',
|
|
|
|
'group' => 'root',
|
|
|
|
'mode' => '0644',
|
|
|
|
})
|
|
|
|
}
|
2015-07-23 18:15:53 +02:00
|
|
|
|
|
|
|
context "with notify_update = true (default)" do
|
|
|
|
let :params do
|
|
|
|
default_params
|
|
|
|
end
|
|
|
|
it { is_expected.to contain_apt__setting("conf-#{title}").with_notify_update(true) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with notify_update = false" do
|
|
|
|
let :params do
|
|
|
|
default_params.merge({
|
|
|
|
:notify_update => false
|
|
|
|
})
|
|
|
|
end
|
|
|
|
it { is_expected.to contain_apt__setting("conf-#{title}").with_notify_update(false) }
|
|
|
|
end
|
2012-04-12 02:49:30 +02:00
|
|
|
end
|
2012-05-04 01:59:13 +02:00
|
|
|
|
2015-04-14 12:41:57 +02:00
|
|
|
describe "when creating a preference without content" do
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
:priority => '00',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'fails' do
|
2015-04-23 01:31:47 +02:00
|
|
|
expect { subject.call } .to raise_error(/pass in content/)
|
2015-04-14 12:41:57 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-05-04 01:59:13 +02:00
|
|
|
describe "when removing an apt preference" do
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
:ensure => 'absent',
|
|
|
|
:priority => '00',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
let :filename do
|
|
|
|
"/etc/apt/apt.conf.d/00norecommends"
|
|
|
|
end
|
|
|
|
|
2015-02-24 22:20:29 +01:00
|
|
|
it { is_expected.to contain_file(filename).with({
|
2012-05-04 01:59:13 +02:00
|
|
|
'ensure' => 'absent',
|
|
|
|
'owner' => 'root',
|
|
|
|
'group' => 'root',
|
|
|
|
'mode' => '0644',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
end
|
2012-04-12 02:49:30 +02:00
|
|
|
end
|