require 'spec_helper'
describe 'apt', :type => :class do
+ let(:facts) { { :lsbdistid => 'Debian' } }
let :default_params do
{
:disable_keys => :undef,
:purge_sources_list => true,
:purge_sources_list_d => true,
},
+ {
+ :purge_preferences => true,
+ :purge_preferences_d => true,
+ },
{
:disable_keys => false
}
end
end
- it { should include_class("apt::params") }
+ it { should contain_class("apt::params") }
it {
if param_hash[:purge_sources_list]
})
end
}
+ it {
+ if param_hash[:purge_preferences]
+ should create_file('apt-preferences').with({
+ :ensure => 'present',
+ :path => '/etc/apt/preferences',
+ :owner => 'root',
+ :group => 'root',
+ :mode => '0644',
+ :content => /Explanation/,
+ })
+ else
+ should create_file('apt-preferences').with({
+ :ensure => 'present',
+ :path => '/etc/apt/preferences',
+ :owner => 'root',
+ :group => 'root',
+ :mode => '0644',
+ :content => nil,
+ })
+ end
+ }
+
+ it {
+ if param_hash[:purge_preferences_d]
+ should create_file("preferences.d").with({
+ 'path' => "/etc/apt/preferences.d",
+ 'ensure' => "directory",
+ 'owner' => "root",
+ 'group' => "root",
+ 'purge' => true,
+ 'recurse' => true,
+ })
+ else
+ should create_file("preferences.d").with({
+ 'path' => "/etc/apt/preferences.d",
+ 'ensure' => "directory",
+ 'owner' => "root",
+ 'group' => "root",
+ 'purge' => false,
+ 'recurse' => false,
+ })
+ end
+ }
it {
should contain_exec("apt_update").with({
'notify' => "Exec[apt_update]"
)
else
- should_not contain_file('configure_apt_proxy')
+ should contain_file('configure-apt-proxy').with(
+ 'path' => '/etc/apt/apt.conf.d/proxy',
+ 'notify' => 'Exec[apt_update]',
+ 'ensure' => 'absent'
+ )
end
}
end