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 'ensure=absent' do
96 let(:params) { { :proxy => { 'ensure' => 'absent'} } }
97 it { is_expected.to contain_apt__setting('conf-proxy').with({
103 context 'lots of non-defaults' do
106 :update => { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 },
107 :purge => { 'sources.list' => false, 'sources.list.d' => false,
108 'preferences' => false, 'preferences.d' => false, },
112 it { is_expected.to contain_file('sources.list').with({
116 it { is_expected.to contain_file('sources.list.d').with({
121 it { is_expected.to contain_file('preferences').with({
125 it { is_expected.to contain_file('preferences.d').with({
130 it { is_expected.to contain_exec('apt_update').with({
131 :refreshonly => false,
138 context 'with sources defined on valid osfamily' do
140 { :osfamily => 'Debian',
141 :lsbdistcodename => 'precise',
142 :lsbdistid => 'Debian',
143 :puppetversion => Puppet.version,
146 let(:params) { { :sources => {
147 'debian_unstable' => {
148 'location' => 'http://debian.mirror.iweb.ca/debian/',
149 'release' => 'unstable',
150 'repos' => 'main contrib non-free',
151 'key' => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' },
153 'include' => {'src' => true,},
156 'location' => 'http://apt.puppetlabs.com',
158 'key' => { 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', 'server' => 'pgp.mit.edu' },
163 is_expected.to contain_apt__setting('list-debian_unstable').with({
164 :ensure => 'present',
168 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$/) }
169 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$/) }
172 is_expected.to contain_apt__setting('list-puppetlabs').with({
173 :ensure => 'present',
177 it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
180 context 'with keys defined on valid osfamily' do
182 { :osfamily => 'Debian',
183 :lsbdistcodename => 'precise',
184 :lsbdistid => 'Debian',
185 :puppetversion => Puppet.version,
188 let(:params) { { :keys => {
190 'server' => 'subkeys.pgp.net',
193 'server' => 'pgp.mit.edu',
197 it { is_expected.to contain_apt__key('55BE302B').with({
198 :server => 'subkeys.pgp.net',
201 it { is_expected.to contain_apt__key('4BD6EC30').with({
202 :server => 'pgp.mit.edu',
206 context 'with ppas defined on valid osfamily' do
208 { :osfamily => 'Debian',
209 :lsbdistcodename => 'precise',
210 :lsbdistid => 'ubuntu',
211 :lsbdistrelease => '12.04',
212 :puppetversion => Puppet.version,
215 let(:params) { { :ppas => {
216 'ppa:drizzle-developers/ppa' => {},
217 'ppa:nginx/stable' => {},
220 it { is_expected.to contain_apt__ppa('ppa:drizzle-developers/ppa')}
221 it { is_expected.to contain_apt__ppa('ppa:nginx/stable')}
224 context 'with settings defined on valid osfamily' do
226 { :osfamily => 'Debian',
227 :lsbdistcodename => 'precise',
228 :lsbdistid => 'Debian',
229 :puppetversion => Puppet.version,
232 let(:params) { { :settings => {
233 'conf-banana' => { 'content' => 'banana' },
234 'pref-banana' => { 'content' => 'banana' },
237 it { is_expected.to contain_apt__setting('conf-banana')}
238 it { is_expected.to contain_apt__setting('pref-banana')}
241 context 'with pins defined on valid osfamily' do
243 { :osfamily => 'Debian',
244 :lsbdistcodename => 'precise',
245 :lsbdistid => 'Debian',
246 :puppetversion => Puppet.version,
249 let(:params) { { :pins => {
250 'stable' => { 'priority' => 600, 'order' => 50 },
251 'testing' => { 'priority' => 700, 'order' => 100 },
254 it { is_expected.to contain_apt__pin('stable') }
255 it { is_expected.to contain_apt__pin('testing') }
258 describe 'failing tests' do
259 context "purge['sources.list']=>'banana'" do
260 let(:params) { { :purge => { 'sources.list' => 'banana' }, } }
264 }.to raise_error(Puppet::Error)
268 context "purge['sources.list.d']=>'banana'" do
269 let(:params) { { :purge => { 'sources.list.d' => 'banana' }, } }
273 }.to raise_error(Puppet::Error)
277 context "purge['preferences']=>'banana'" do
278 let(:params) { { :purge => { 'preferences' => 'banana' }, } }
282 }.to raise_error(Puppet::Error)
286 context "purge['preferences.d']=>'banana'" do
287 let(:params) { { :purge => { 'preferences.d' => 'banana' }, } }
291 }.to raise_error(Puppet::Error)
295 context 'with unsupported osfamily' do
297 { :osfamily => 'Darwin', :puppetversion => Puppet.version,}
303 }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)