5 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
6 :lsbdistid => 'Debian',
8 :lsbdistcodename => 'wheezy',
9 :puppetversion => Puppet.version,
13 it { is_expected.to contain_file('sources.list').that_notifies('Class[Apt::Update]').only_with({
15 :path => '/etc/apt/sources.list',
19 :notify => 'Class[Apt::Update]',
22 it { is_expected.to contain_file('sources.list.d').that_notifies('Class[Apt::Update]').only_with({
23 :ensure => 'directory',
24 :path => '/etc/apt/sources.list.d',
30 :notify => 'Class[Apt::Update]',
33 it { is_expected.to contain_file('preferences').that_notifies('Class[Apt::Update]').only_with({
35 :path => '/etc/apt/preferences',
39 :notify => 'Class[Apt::Update]',
42 it { is_expected.to contain_file('preferences.d').that_notifies('Class[Apt::Update]').only_with({
43 :ensure => 'directory',
44 :path => '/etc/apt/preferences.d',
50 :notify => 'Class[Apt::Update]',
53 it 'should lay down /etc/apt/apt.conf.d/15update-stamp' do
54 is_expected.to contain_file('/etc/apt/apt.conf.d/15update-stamp').with({
58 }).with_content(/APT::Update::Post-Invoke-Success \{"touch \/var\/lib\/apt\/periodic\/update-success-stamp 2>\/dev\/null \|\| true";\};/)
61 it { is_expected.to contain_exec('apt_update').with({
62 :refreshonly => 'true',
65 it { is_expected.not_to contain_apt__setting('conf-proxy') }
69 context 'host=localhost' do
70 let(:params) { { :proxy => { 'host' => 'localhost'} } }
71 it { is_expected.to contain_apt__setting('conf-proxy').with({
74 /Acquire::http::proxy "http:\/\/localhost:8080\/";/
76 /Acquire::https::proxy/
80 context 'host=localhost and port=8180' do
81 let(:params) { { :proxy => { 'host' => 'localhost', 'port' => 8180} } }
82 it { is_expected.to contain_apt__setting('conf-proxy').with({
85 /Acquire::http::proxy "http:\/\/localhost:8180\/";/
87 /Acquire::https::proxy/
91 context 'host=localhost and https=true' do
92 let(:params) { { :proxy => { 'host' => 'localhost', 'https' => true} } }
93 it { is_expected.to contain_apt__setting('conf-proxy').with({
96 /Acquire::http::proxy "http:\/\/localhost:8080\/";/
98 /Acquire::https::proxy "https:\/\/localhost:8080\/";/
102 context 'ensure=absent' do
103 let(:params) { { :proxy => { 'ensure' => 'absent'} } }
104 it { is_expected.to contain_apt__setting('conf-proxy').with({
110 context 'lots of non-defaults' do
113 :update => { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 },
114 :purge => { 'sources.list' => false, 'sources.list.d' => false,
115 'preferences' => false, 'preferences.d' => false, },
119 it { is_expected.to contain_file('sources.list').with({
123 it { is_expected.to contain_file('sources.list.d').with({
128 it { is_expected.to contain_file('preferences').with({
132 it { is_expected.to contain_file('preferences.d').with({
137 it { is_expected.to contain_exec('apt_update').with({
138 :refreshonly => false,
145 context 'with sources defined on valid osfamily' do
147 { :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04' }},
148 :osfamily => 'Debian',
149 :lsbdistcodename => 'precise',
150 :lsbdistid => 'Ubuntu',
151 :lsbdistrelease => '12.04',
152 :puppetversion => Puppet.version,
155 let(:params) { { :sources => {
156 'debian_unstable' => {
157 'location' => 'http://debian.mirror.iweb.ca/debian/',
158 'release' => 'unstable',
159 'repos' => 'main contrib non-free',
160 'key' => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' },
162 'include' => {'src' => true,},
165 'location' => 'http://apt.puppetlabs.com',
167 'key' => { 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', 'server' => 'pgp.mit.edu' },
172 is_expected.to contain_apt__setting('list-debian_unstable').with({
173 :ensure => 'present',
177 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$/) }
178 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$/) }
181 is_expected.to contain_apt__setting('list-puppetlabs').with({
182 :ensure => 'present',
186 it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
189 context 'with confs defined on valid osfamily' do
192 :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04.5' }},
193 :osfamily => 'Debian',
194 :lsbdistcodename => 'precise',
195 :lsbdistid => 'Debian',
196 :puppetversion => Puppet.version,
199 let(:params) { { :confs => {
208 it { is_expected.to contain_apt__conf('foo').with({
212 it { is_expected.to contain_apt__conf('bar').with({
217 context 'with keys defined on valid osfamily' do
220 :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04.5' }},
221 :osfamily => 'Debian',
222 :lsbdistcodename => 'precise',
223 :lsbdistid => 'Debian',
224 :puppetversion => Puppet.version,
227 let(:params) { { :keys => {
229 'server' => 'subkeys.pgp.net',
232 'server' => 'pgp.mit.edu',
236 it { is_expected.to contain_apt__key('55BE302B').with({
237 :server => 'subkeys.pgp.net',
240 it { is_expected.to contain_apt__key('EF8D349F').with({
241 :server => 'pgp.mit.edu',
245 context 'with ppas defined on valid osfamily' do
248 :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04.5' }},
249 :osfamily => 'Debian',
250 :lsbdistcodename => 'precise',
251 :lsbdistid => 'ubuntu',
252 :lsbdistrelease => '12.04',
253 :puppetversion => Puppet.version,
256 let(:params) { { :ppas => {
257 'ppa:drizzle-developers/ppa' => {},
258 'ppa:nginx/stable' => {},
261 it { is_expected.to contain_apt__ppa('ppa:drizzle-developers/ppa')}
262 it { is_expected.to contain_apt__ppa('ppa:nginx/stable')}
265 context 'with settings defined on valid osfamily' do
268 :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04.5' }},
269 :osfamily => 'Debian',
270 :lsbdistcodename => 'precise',
271 :lsbdistid => 'Debian',
272 :puppetversion => Puppet.version,
275 let(:params) { { :settings => {
276 'conf-banana' => { 'content' => 'banana' },
277 'pref-banana' => { 'content' => 'banana' },
280 it { is_expected.to contain_apt__setting('conf-banana')}
281 it { is_expected.to contain_apt__setting('pref-banana')}
284 context 'with pins defined on valid osfamily' do
287 :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04.5' }},
288 :osfamily => 'Debian',
289 :lsbdistcodename => 'precise',
290 :lsbdistid => 'Debian',
291 :puppetversion => Puppet.version,
294 let(:params) { { :pins => {
295 'stable' => { 'priority' => 600, 'order' => 50 },
296 'testing' => { 'priority' => 700, 'order' => 100 },
299 it { is_expected.to contain_apt__pin('stable') }
300 it { is_expected.to contain_apt__pin('testing') }
303 describe 'failing tests' do
304 context "purge['sources.list']=>'banana'" do
305 let(:params) { { :purge => { 'sources.list' => 'banana' }, } }
309 }.to raise_error(Puppet::Error)
313 context "purge['sources.list.d']=>'banana'" do
314 let(:params) { { :purge => { 'sources.list.d' => 'banana' }, } }
318 }.to raise_error(Puppet::Error)
322 context "purge['preferences']=>'banana'" do
323 let(:params) { { :purge => { 'preferences' => 'banana' }, } }
327 }.to raise_error(Puppet::Error)
331 context "purge['preferences.d']=>'banana'" do
332 let(:params) { { :purge => { 'preferences.d' => 'banana' }, } }
336 }.to raise_error(Puppet::Error)