3 let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
6 it { is_expected.to contain_file('sources.list').that_notifies('Exec[apt_update]').only_with({
8 :path => '/etc/apt/sources.list',
12 :content => "# Repos managed by puppet.\n",
13 :notify => 'Exec[apt_update]',
16 it { is_expected.to contain_file('sources.list.d').that_notifies('Exec[apt_update]').only_with({
17 :ensure => 'directory',
18 :path => '/etc/apt/sources.list.d',
24 :notify => 'Exec[apt_update]',
27 it { is_expected.to contain_file('preferences').that_notifies('Exec[apt_update]').only_with({
29 :path => '/etc/apt/preferences',
33 :notify => 'Exec[apt_update]',
36 it { is_expected.to contain_file('preferences.d').that_notifies('Exec[apt_update]').only_with({
37 :ensure => 'directory',
38 :path => '/etc/apt/preferences.d',
44 :notify => 'Exec[apt_update]',
47 it 'should lay down /etc/apt/apt.conf.d/15update-stamp' do
48 is_expected.to contain_file('/etc/apt/apt.conf.d/15update-stamp').with({
52 }).with_content(/APT::Update::Post-Invoke-Success \{"touch \/var\/lib\/apt\/periodic\/update-success-stamp 2>\/dev\/null \|\| true";\};/)
55 it { is_expected.to contain_exec('apt_update').with({
56 :refreshonly => 'true',
59 it { is_expected.not_to contain_apt__setting('conf-proxy') }
63 context 'host=localhost' do
64 let(:params) { { :proxy => { 'host' => 'localhost'} } }
65 it { is_expected.to contain_apt__setting('conf-proxy').with({
68 /Acquire::http::proxy "http:\/\/localhost:8080\/";/
70 /Acquire::https::proxy/
74 context 'host=localhost and port=8180' do
75 let(:params) { { :proxy => { 'host' => 'localhost', 'port' => 8180} } }
76 it { is_expected.to contain_apt__setting('conf-proxy').with({
79 /Acquire::http::proxy "http:\/\/localhost:8180\/";/
81 /Acquire::https::proxy/
85 context 'host=localhost and https=true' do
86 let(:params) { { :proxy => { 'host' => 'localhost', 'https' => true} } }
87 it { is_expected.to contain_apt__setting('conf-proxy').with({
90 /Acquire::http::proxy "http:\/\/localhost:8080\/";/
92 /Acquire::https::proxy "https:\/\/localhost:8080\/";/
96 context 'lots of non-defaults' do
99 :update => { 'always' => true, 'timeout' => 1, 'tries' => 3 },
100 :purge => { 'sources.list' => false, 'sources.list.d' => false,
101 'preferences' => false, 'preferences.d' => false, },
105 it { is_expected.to contain_file('sources.list').without({
106 :content => "# Repos managed by puppet.\n",
109 it { is_expected.to contain_file('sources.list.d').with({
114 it { is_expected.to contain_file('preferences').with({
118 it { is_expected.to contain_file('preferences.d').with({
123 it { is_expected.to contain_exec('apt_update').with({
124 :refreshonly => false,
131 context 'with sources defined on valid osfamily' do
133 { :osfamily => 'Debian',
134 :lsbdistcodename => 'precise',
135 :lsbdistid => 'Debian',
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' => '55BE302B', 'server' => 'subkeys.pgp.net' },
145 'include_src' => true,
148 'location' => 'http://apt.puppetlabs.com',
150 'key' => { 'id' => '4BD6EC30', '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',
179 let(:params) { { :keys => {
181 'server' => 'subkeys.pgp.net',
184 'server' => 'pgp.mit.edu',
188 it { is_expected.to contain_apt__key('55BE302B').with({
189 :server => 'subkeys.pgp.net',
192 it { is_expected.to contain_apt__key('4BD6EC30').with({
193 :server => 'pgp.mit.edu',
197 context 'with ppas defined on valid osfamily' do
199 { :osfamily => 'Debian',
200 :lsbdistcodename => 'precise',
201 :lsbdistid => 'ubuntu',
204 let(:params) { { :ppas => {
205 'ppa:drizzle-developers/ppa' => {},
206 'ppa:nginx/stable' => {},
209 it { is_expected.to contain_apt__ppa('ppa:drizzle-developers/ppa')}
210 it { is_expected.to contain_apt__ppa('ppa:nginx/stable')}
213 context 'with settings defined on valid osfamily' do
215 { :osfamily => 'Debian',
216 :lsbdistcodename => 'precise',
217 :lsbdistid => 'Debian',
220 let(:params) { { :settings => {
221 'conf-banana' => { 'content' => 'banana' },
222 'pref-banana' => { 'content' => 'banana' },
225 it { is_expected.to contain_apt__setting('conf-banana')}
226 it { is_expected.to contain_apt__setting('pref-banana')}
229 describe 'failing tests' do
230 context "purge['sources.list']=>'banana'" do
231 let(:params) { { :purge => { 'sources.list' => 'banana' }, } }
234 is_expected.to compile
235 }.to raise_error(Puppet::Error)
239 context "purge['sources.list.d']=>'banana'" do
240 let(:params) { { :purge => { 'sources.list.d' => 'banana' }, } }
243 is_expected.to compile
244 }.to raise_error(Puppet::Error)
248 context "purge['preferences']=>'banana'" do
249 let(:params) { { :purge => { 'preferences' => 'banana' }, } }
252 is_expected.to compile
253 }.to raise_error(Puppet::Error)
257 context "purge['preferences.d']=>'banana'" do
258 let(:params) { { :purge => { 'preferences.d' => 'banana' }, } }
261 is_expected.to compile
262 }.to raise_error(Puppet::Error)
266 context 'with unsupported osfamily' do
268 { :osfamily => 'Darwin', }
273 is_expected.to compile
274 }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)