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 :always_apt_update => true,
100 :purge => { 'sources.list' => false, 'sources.list.d' => false,
101 'preferences' => false, 'preferences.d' => false, },
102 :update_timeout => '1',
103 :update_tries => '3',
107 it { is_expected.to contain_file('sources.list').without({
108 :content => "# Repos managed by puppet.\n",
111 it { is_expected.to contain_file('sources.list.d').with({
116 it { is_expected.to contain_file('preferences').with({
120 it { is_expected.to contain_file('preferences.d').with({
125 it { is_expected.to contain_exec('apt_update').with({
126 :refreshonly => 'false',
133 context 'with sources defined on valid osfamily' do
135 { :osfamily => 'Debian',
136 :lsbdistcodename => 'precise',
137 :lsbdistid => 'Debian',
140 let(:params) { { :sources => {
141 'debian_unstable' => {
142 'location' => 'http://debian.mirror.iweb.ca/debian/',
143 'release' => 'unstable',
144 'repos' => 'main contrib non-free',
146 'key_server' => 'subkeys.pgp.net',
148 'include_src' => true,
151 'location' => 'http://apt.puppetlabs.com',
154 'key_server' => 'pgp.mit.edu',
159 is_expected.to contain_apt__setting('list-debian_unstable').with({
160 :ensure => 'present',
164 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$/) }
165 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$/) }
168 is_expected.to contain_apt__setting('list-puppetlabs').with({
169 :ensure => 'present',
173 it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
176 describe 'failing tests' do
177 context "purge['sources.list']=>'banana'" do
178 let(:params) { { :purge => { 'sources.list' => 'banana' }, } }
181 is_expected.to compile
182 }.to raise_error(Puppet::Error)
186 context "purge['sources.list.d']=>'banana'" do
187 let(:params) { { :purge => { 'sources.list.d' => 'banana' }, } }
190 is_expected.to compile
191 }.to raise_error(Puppet::Error)
195 context "purge['preferences']=>'banana'" do
196 let(:params) { { :purge => { 'preferences' => 'banana' }, } }
199 is_expected.to compile
200 }.to raise_error(Puppet::Error)
204 context "purge['preferences.d']=>'banana'" do
205 let(:params) { { :purge => { 'preferences.d' => 'banana' }, } }
208 is_expected.to compile
209 }.to raise_error(Puppet::Error)
213 context 'with unsupported osfamily' do
215 { :osfamily => 'Darwin', }
220 is_expected.to compile
221 }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)