- it { should contain_class("apt::params") }
-
- it {
- if param_hash[:purge_sources_list]
- should contain_file("sources.list").with({
- 'path' => "/etc/apt/sources.list",
- 'ensure' => "present",
- 'owner' => "root",
- 'group' => "root",
- 'mode' => "0644",
- "content" => "# Repos managed by puppet.\n"
- })
- else
- should contain_file("sources.list").with({
- 'path' => "/etc/apt/sources.list",
- 'ensure' => "present",
- 'owner' => "root",
- 'group' => "root",
- 'mode' => "0644",
- 'content' => nil
- })
- end
+ context 'ensure=absent' do
+ let(:params) { { :proxy => { 'ensure' => 'absent'} } }
+ it { is_expected.to contain_apt__setting('conf-proxy').with({
+ :ensure => 'absent',
+ :priority => '01',
+ })}
+ end
+ end
+ context 'lots of non-defaults' do
+ let :params do
+ {
+ :update => { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 },
+ :purge => { 'sources.list' => false, 'sources.list.d' => false,
+ 'preferences' => false, 'preferences.d' => false, },
+ }
+ end
+
+ it { is_expected.to contain_file('sources.list').with({
+ :content => nil,
+ })}
+
+ it { is_expected.to contain_file('sources.list.d').with({
+ :purge => false,
+ :recurse => false,
+ })}
+
+ it { is_expected.to contain_file('preferences').with({
+ :ensure => 'file',
+ })}
+
+ it { is_expected.to contain_file('preferences.d').with({
+ :purge => false,
+ :recurse => false,
+ })}
+
+ it { is_expected.to contain_exec('apt_update').with({
+ :refreshonly => false,
+ :timeout => 1,
+ :tries => 3,
+ })}
+
+ end
+
+ context 'with sources defined on valid osfamily' do
+ let :facts do
+ { :osfamily => 'Debian',
+ :lsbdistcodename => 'precise',
+ :lsbdistid => 'Debian',
+ :puppetversion => Puppet.version,
+ }
+ end
+ let(:params) { { :sources => {
+ 'debian_unstable' => {
+ 'location' => 'http://debian.mirror.iweb.ca/debian/',
+ 'release' => 'unstable',
+ 'repos' => 'main contrib non-free',
+ 'key' => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' },
+ 'pin' => '-10',
+ 'include' => {'src' => true,},
+ },
+ 'puppetlabs' => {
+ 'location' => 'http://apt.puppetlabs.com',
+ 'repos' => 'main',
+ 'key' => { 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', 'server' => 'pgp.mit.edu' },