4 { :lsbdistid => 'Debian',
6 :lsbdistcodename => 'wheezy',
7 :puppetversion => Puppet.version,
11 it { is_expected.to contain_file('sources.list').that_notifies('Class[Apt::Update]').only_with({
13 :path => '/etc/apt/sources.list',
17 :notify => 'Class[Apt::Update]',
20 it { is_expected.to contain_file('sources.list.d').that_notifies('Class[Apt::Update]').only_with({
21 :ensure => 'directory',
22 :path => '/etc/apt/sources.list.d',
28 :notify => 'Class[Apt::Update]',
31 it { is_expected.to contain_file('preferences').that_notifies('Class[Apt::Update]').only_with({
33 :path => '/etc/apt/preferences',
37 :notify => 'Class[Apt::Update]',
40 it { is_expected.to contain_file('preferences.d').that_notifies('Class[Apt::Update]').only_with({
41 :ensure => 'directory',
42 :path => '/etc/apt/preferences.d',
48 :notify => 'Class[Apt::Update]',
51 it 'should lay down /etc/apt/apt.conf.d/15update-stamp' do
52 is_expected.to contain_file('/etc/apt/apt.conf.d/15update-stamp').with({
56 }).with_content(/APT::Update::Post-Invoke-Success \{"touch \/var\/lib\/apt\/periodic\/update-success-stamp 2>\/dev\/null \|\| true";\};/)
59 it { is_expected.to contain_exec('apt_update').with({
60 :refreshonly => 'true',
63 it { is_expected.not_to contain_apt__setting('conf-proxy') }
67 context 'host=localhost' do
68 let(:params) { { :proxy => { 'host' => 'localhost'} } }
69 it { is_expected.to contain_apt__setting('conf-proxy').with({
72 /Acquire::http::proxy "http:\/\/localhost:8080\/";/
74 /Acquire::https::proxy/
78 context 'host=localhost and port=8180' do
79 let(:params) { { :proxy => { 'host' => 'localhost', 'port' => 8180} } }
80 it { is_expected.to contain_apt__setting('conf-proxy').with({
83 /Acquire::http::proxy "http:\/\/localhost:8180\/";/
85 /Acquire::https::proxy/
89 context 'host=localhost and https=true' do
90 let(:params) { { :proxy => { 'host' => 'localhost', 'https' => true} } }
91 it { is_expected.to contain_apt__setting('conf-proxy').with({
94 /Acquire::http::proxy "http:\/\/localhost:8080\/";/
96 /Acquire::https::proxy "https:\/\/localhost:8080\/";/
100 context 'ensure=absent' do
101 let(:params) { { :proxy => { 'ensure' => 'absent'} } }
102 it { is_expected.to contain_apt__setting('conf-proxy').with({
108 context 'lots of non-defaults' do
111 :update => { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 },
112 :purge => { 'sources.list' => false, 'sources.list.d' => false,
113 'preferences' => false, 'preferences.d' => false, },
117 it { is_expected.to contain_file('sources.list').with({
121 it { is_expected.to contain_file('sources.list.d').with({
126 it { is_expected.to contain_file('preferences').with({
130 it { is_expected.to contain_file('preferences.d').with({
135 it { is_expected.to contain_exec('apt_update').with({
136 :refreshonly => false,
143 context 'with sources defined on valid osfamily' do
145 { :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04' }},
146 :osfamily => 'Debian',
147 :lsbdistcodename => 'precise',
148 :lsbdistid => 'Ubuntu',
149 :lsbdistrelease => '12.04',
150 :puppetversion => Puppet.version,
153 let(:params) { { :sources => {
154 'debian_unstable' => {
155 'location' => 'http://debian.mirror.iweb.ca/debian/',
156 'release' => 'unstable',
157 'repos' => 'main contrib non-free',
158 'key' => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' },
160 'include' => {'src' => true,},
163 'location' => 'http://apt.puppetlabs.com',
165 'key' => { 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', 'server' => 'pgp.mit.edu' },
170 is_expected.to contain_apt__setting('list-debian_unstable').with({
171 :ensure => 'present',
175 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$/) }
176 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$/) }
179 is_expected.to contain_apt__setting('list-puppetlabs').with({
180 :ensure => 'present',
184 it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
187 context 'with confs defined on valid osfamily' do
189 { :osfamily => 'Debian',
190 :lsbdistcodename => 'precise',
191 :lsbdistid => 'Debian',
192 :puppetversion => Puppet.version,
195 let(:params) { { :confs => {
204 it { is_expected.to contain_apt__conf('foo').with({
208 it { is_expected.to contain_apt__conf('bar').with({
213 context 'with keys defined on valid osfamily' do
215 { :osfamily => 'Debian',
216 :lsbdistcodename => 'precise',
217 :lsbdistid => 'Debian',
218 :puppetversion => Puppet.version,
221 let(:params) { { :keys => {
223 'server' => 'subkeys.pgp.net',
226 'server' => 'pgp.mit.edu',
230 it { is_expected.to contain_apt__key('55BE302B').with({
231 :server => 'subkeys.pgp.net',
234 it { is_expected.to contain_apt__key('EF8D349F').with({
235 :server => 'pgp.mit.edu',
239 context 'with ppas defined on valid osfamily' do
241 { :osfamily => 'Debian',
242 :lsbdistcodename => 'precise',
243 :lsbdistid => 'ubuntu',
244 :lsbdistrelease => '12.04',
245 :puppetversion => Puppet.version,
248 let(:params) { { :ppas => {
249 'ppa:drizzle-developers/ppa' => {},
250 'ppa:nginx/stable' => {},
253 it { is_expected.to contain_apt__ppa('ppa:drizzle-developers/ppa')}
254 it { is_expected.to contain_apt__ppa('ppa:nginx/stable')}
257 context 'with settings defined on valid osfamily' do
259 { :osfamily => 'Debian',
260 :lsbdistcodename => 'precise',
261 :lsbdistid => 'Debian',
262 :puppetversion => Puppet.version,
265 let(:params) { { :settings => {
266 'conf-banana' => { 'content' => 'banana' },
267 'pref-banana' => { 'content' => 'banana' },
270 it { is_expected.to contain_apt__setting('conf-banana')}
271 it { is_expected.to contain_apt__setting('pref-banana')}
274 context 'with pins defined on valid osfamily' do
276 { :osfamily => 'Debian',
277 :lsbdistcodename => 'precise',
278 :lsbdistid => 'Debian',
279 :puppetversion => Puppet.version,
282 let(:params) { { :pins => {
283 'stable' => { 'priority' => 600, 'order' => 50 },
284 'testing' => { 'priority' => 700, 'order' => 100 },
287 it { is_expected.to contain_apt__pin('stable') }
288 it { is_expected.to contain_apt__pin('testing') }
291 describe 'failing tests' do
292 context "purge['sources.list']=>'banana'" do
293 let(:params) { { :purge => { 'sources.list' => 'banana' }, } }
297 }.to raise_error(Puppet::Error)
301 context "purge['sources.list.d']=>'banana'" do
302 let(:params) { { :purge => { 'sources.list.d' => 'banana' }, } }
306 }.to raise_error(Puppet::Error)
310 context "purge['preferences']=>'banana'" do
311 let(:params) { { :purge => { 'preferences' => 'banana' }, } }
315 }.to raise_error(Puppet::Error)
319 context "purge['preferences.d']=>'banana'" do
320 let(:params) { { :purge => { 'preferences.d' => 'banana' }, } }
324 }.to raise_error(Puppet::Error)
328 context 'with unsupported osfamily' do
330 { :osfamily => 'Darwin', :puppetversion => Puppet.version,}
336 }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)