3 let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy'} }
6 it { is_expected.to contain_file('sources.list').that_notifies('Exec[apt_update]').only_with({
8 :path => '/etc/apt/sources.list',
12 :notify => 'Exec[apt_update]',
15 it { is_expected.to contain_file('sources.list.d').that_notifies('Exec[apt_update]').only_with({
16 :ensure => 'directory',
17 :path => '/etc/apt/sources.list.d',
23 :notify => 'Exec[apt_update]',
26 it { is_expected.to contain_file('preferences').that_notifies('Exec[apt_update]').only_with({
28 :path => '/etc/apt/preferences',
32 :notify => 'Exec[apt_update]',
35 it { is_expected.to contain_file('preferences.d').that_notifies('Exec[apt_update]').only_with({
36 :ensure => 'directory',
37 :path => '/etc/apt/preferences.d',
43 :notify => 'Exec[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',
137 let(:params) { { :sources => {
138 'debian_unstable' => {
139 'location' => 'http://debian.mirror.iweb.ca/debian/',
140 'release' => 'unstable',
141 'repos' => 'main contrib non-free',
142 'key' => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' },
144 'include' => {'src' => true,},
147 'location' => 'http://apt.puppetlabs.com',
149 'key' => { 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', 'server' => 'pgp.mit.edu' },
154 is_expected.to contain_apt__setting('list-debian_unstable').with({
155 :ensure => 'present',
159 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$/) }
160 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$/) }
163 is_expected.to contain_apt__setting('list-puppetlabs').with({
164 :ensure => 'present',
168 it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
171 context 'with keys defined on valid osfamily' do
173 { :osfamily => 'Debian',
174 :lsbdistcodename => 'precise',
175 :lsbdistid => 'Debian',
178 let(:params) { { :keys => {
180 'server' => 'subkeys.pgp.net',
183 'server' => 'pgp.mit.edu',
187 it { is_expected.to contain_apt__key('55BE302B').with({
188 :server => 'subkeys.pgp.net',
191 it { is_expected.to contain_apt__key('4BD6EC30').with({
192 :server => 'pgp.mit.edu',
196 context 'with ppas defined on valid osfamily' do
198 { :osfamily => 'Debian',
199 :lsbdistcodename => 'precise',
200 :lsbdistid => 'ubuntu',
203 let(:params) { { :ppas => {
204 'ppa:drizzle-developers/ppa' => {},
205 'ppa:nginx/stable' => {},
208 it { is_expected.to contain_apt__ppa('ppa:drizzle-developers/ppa')}
209 it { is_expected.to contain_apt__ppa('ppa:nginx/stable')}
212 context 'with settings defined on valid osfamily' do
214 { :osfamily => 'Debian',
215 :lsbdistcodename => 'precise',
216 :lsbdistid => 'Debian',
219 let(:params) { { :settings => {
220 'conf-banana' => { 'content' => 'banana' },
221 'pref-banana' => { 'content' => 'banana' },
224 it { is_expected.to contain_apt__setting('conf-banana')}
225 it { is_expected.to contain_apt__setting('pref-banana')}
228 describe 'failing tests' do
229 context "purge['sources.list']=>'banana'" do
230 let(:params) { { :purge => { 'sources.list' => 'banana' }, } }
234 }.to raise_error(Puppet::Error)
238 context "purge['sources.list.d']=>'banana'" do
239 let(:params) { { :purge => { 'sources.list.d' => 'banana' }, } }
243 }.to raise_error(Puppet::Error)
247 context "purge['preferences']=>'banana'" do
248 let(:params) { { :purge => { 'preferences' => 'banana' }, } }
252 }.to raise_error(Puppet::Error)
256 context "purge['preferences.d']=>'banana'" do
257 let(:params) { { :purge => { 'preferences.d' => 'banana' }, } }
261 }.to raise_error(Puppet::Error)
265 context 'with unsupported osfamily' do
267 { :osfamily => 'Darwin', }
273 }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)