3 let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version} }
6 it { is_expected.to contain_file('sources.list').that_notifies('Class[Apt::Update]').only_with({
8 :path => '/etc/apt/sources.list',
12 :notify => 'Class[Apt::Update]',
15 it { is_expected.to contain_file('sources.list.d').that_notifies('Class[Apt::Update]').only_with({
16 :ensure => 'directory',
17 :path => '/etc/apt/sources.list.d',
23 :notify => 'Class[Apt::Update]',
26 it { is_expected.to contain_file('preferences').that_notifies('Class[Apt::Update]').only_with({
28 :path => '/etc/apt/preferences',
32 :notify => 'Class[Apt::Update]',
35 it { is_expected.to contain_file('preferences.d').that_notifies('Class[Apt::Update]').only_with({
36 :ensure => 'directory',
37 :path => '/etc/apt/preferences.d',
43 :notify => 'Class[Apt::Update]',
46 it 'should lay down /etc/apt/apt.conf.d/15update-stamp' do
47 is_expected.to contain_file('/etc/apt/apt.conf.d/15update-stamp').with({
51 }).with_content(/APT::Update::Post-Invoke-Success \{"touch \/var\/lib\/apt\/periodic\/update-success-stamp 2>\/dev\/null \|\| true";\};/)
54 it { is_expected.to contain_exec('apt_update').with({
55 :refreshonly => 'true',
58 it { is_expected.not_to contain_apt__setting('conf-proxy') }
62 context 'host=localhost' do
63 let(:params) { { :proxy => { 'host' => 'localhost'} } }
64 it { is_expected.to contain_apt__setting('conf-proxy').with({
67 /Acquire::http::proxy "http:\/\/localhost:8080\/";/
69 /Acquire::https::proxy/
73 context 'host=localhost and port=8180' do
74 let(:params) { { :proxy => { 'host' => 'localhost', 'port' => 8180} } }
75 it { is_expected.to contain_apt__setting('conf-proxy').with({
78 /Acquire::http::proxy "http:\/\/localhost:8180\/";/
80 /Acquire::https::proxy/
84 context 'host=localhost and https=true' do
85 let(:params) { { :proxy => { 'host' => 'localhost', 'https' => true} } }
86 it { is_expected.to contain_apt__setting('conf-proxy').with({
89 /Acquire::http::proxy "http:\/\/localhost:8080\/";/
91 /Acquire::https::proxy "https:\/\/localhost:8080\/";/
95 context 'lots of non-defaults' do
98 :update => { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 },
99 :purge => { 'sources.list' => false, 'sources.list.d' => false,
100 'preferences' => false, 'preferences.d' => false, },
104 it { is_expected.to contain_file('sources.list').with({
108 it { is_expected.to contain_file('sources.list.d').with({
113 it { is_expected.to contain_file('preferences').with({
117 it { is_expected.to contain_file('preferences.d').with({
122 it { is_expected.to contain_exec('apt_update').with({
123 :refreshonly => false,
130 context 'with sources defined on valid osfamily' do
132 { :osfamily => 'Debian',
133 :lsbdistcodename => 'precise',
134 :lsbdistid => 'Debian',
135 :puppetversion => Puppet.version,
138 let(:params) { { :sources => {
139 'debian_unstable' => {
140 'location' => 'http://debian.mirror.iweb.ca/debian/',
141 'release' => 'unstable',
142 'repos' => 'main contrib non-free',
143 'key' => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' },
145 'include' => {'src' => true,},
148 'location' => 'http://apt.puppetlabs.com',
150 'key' => { 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', 'server' => 'pgp.mit.edu' },
155 is_expected.to contain_apt__setting('list-debian_unstable').with({
156 :ensure => 'present',
160 it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(/^deb http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
161 it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
164 is_expected.to contain_apt__setting('list-puppetlabs').with({
165 :ensure => 'present',
169 it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
172 context 'with keys defined on valid osfamily' do
174 { :osfamily => 'Debian',
175 :lsbdistcodename => 'precise',
176 :lsbdistid => 'Debian',
177 :puppetversion => Puppet.version,
180 let(:params) { { :keys => {
182 'server' => 'subkeys.pgp.net',
185 'server' => 'pgp.mit.edu',
189 it { is_expected.to contain_apt__key('55BE302B').with({
190 :server => 'subkeys.pgp.net',
193 it { is_expected.to contain_apt__key('4BD6EC30').with({
194 :server => 'pgp.mit.edu',
198 context 'with ppas defined on valid osfamily' do
200 { :osfamily => 'Debian',
201 :lsbdistcodename => 'precise',
202 :lsbdistid => 'ubuntu',
203 :puppetversion => Puppet.version,
206 let(:params) { { :ppas => {
207 'ppa:drizzle-developers/ppa' => {},
208 'ppa:nginx/stable' => {},
211 it { is_expected.to contain_apt__ppa('ppa:drizzle-developers/ppa')}
212 it { is_expected.to contain_apt__ppa('ppa:nginx/stable')}
215 context 'with settings defined on valid osfamily' do
217 { :osfamily => 'Debian',
218 :lsbdistcodename => 'precise',
219 :lsbdistid => 'Debian',
220 :puppetversion => Puppet.version,
223 let(:params) { { :settings => {
224 'conf-banana' => { 'content' => 'banana' },
225 'pref-banana' => { 'content' => 'banana' },
228 it { is_expected.to contain_apt__setting('conf-banana')}
229 it { is_expected.to contain_apt__setting('pref-banana')}
232 describe 'failing tests' do
233 context "purge['sources.list']=>'banana'" do
234 let(:params) { { :purge => { 'sources.list' => 'banana' }, } }
238 }.to raise_error(Puppet::Error)
242 context "purge['sources.list.d']=>'banana'" do
243 let(:params) { { :purge => { 'sources.list.d' => 'banana' }, } }
247 }.to raise_error(Puppet::Error)
251 context "purge['preferences']=>'banana'" do
252 let(:params) { { :purge => { 'preferences' => 'banana' }, } }
256 }.to raise_error(Puppet::Error)
260 context "purge['preferences.d']=>'banana'" do
261 let(:params) { { :purge => { 'preferences.d' => 'banana' }, } }
265 }.to raise_error(Puppet::Error)
269 context 'with unsupported osfamily' do
271 { :osfamily => 'Darwin', :puppetversion => Puppet.version,}
277 }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)