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 :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',
22 :notify => 'Exec[apt_update]',
25 it { is_expected.to contain_file('preferences.d').only_with({
26 :ensure => 'directory',
27 :path => '/etc/apt/preferences.d',
34 it 'should lay down /etc/apt/apt.conf.d/15update-stamp' do
35 is_expected.to contain_file('/etc/apt/apt.conf.d/15update-stamp').with({
39 }).with_content(/APT::Update::Post-Invoke-Success \{"touch \/var\/lib\/apt\/periodic\/update-success-stamp 2>\/dev\/null \|\| true";\};/)
42 it { is_expected.to contain_exec('apt_update').with({
43 :refreshonly => 'true',
46 it { is_expected.not_to contain_apt__setting('conf-proxy') }
50 context 'host=localhost' do
51 let(:params) { { :proxy => { 'host' => 'localhost'} } }
52 it { is_expected.to contain_apt__setting('conf-proxy').with({
55 /Acquire::http::proxy "http:\/\/localhost:8080\/";/
57 /Acquire::https::proxy/
61 context 'host=localhost and port=8180' do
62 let(:params) { { :proxy => { 'host' => 'localhost', 'port' => 8180} } }
63 it { is_expected.to contain_apt__setting('conf-proxy').with({
66 /Acquire::http::proxy "http:\/\/localhost:8180\/";/
68 /Acquire::https::proxy/
72 context 'host=localhost and https=true' do
73 let(:params) { { :proxy => { 'host' => 'localhost', 'https' => true} } }
74 it { is_expected.to contain_apt__setting('conf-proxy').with({
77 /Acquire::http::proxy "http:\/\/localhost:8080\/";/
79 /Acquire::https::proxy "https:\/\/localhost:8080\/";/
83 context 'lots of non-defaults' do
86 :always_apt_update => true,
87 :purge_sources_list => true,
88 :purge_sources_list_d => true,
89 :purge_preferences => true,
90 :purge_preferences_d => true,
91 :update_timeout => '1',
96 it { is_expected.to contain_file('sources.list').with({
97 :content => "# Repos managed by puppet.\n"
100 it { is_expected.to contain_file('sources.list.d').with({
105 it { is_expected.to contain_file('apt-preferences').only_with({
107 :path => '/etc/apt/preferences',
110 it { is_expected.to contain_file('preferences.d').with({
115 it { is_expected.to contain_exec('apt_update').with({
116 :refreshonly => 'false',
123 context 'with sources defined on valid osfamily' do
125 { :osfamily => 'Debian',
126 :lsbdistcodename => 'precise',
127 :lsbdistid => 'Debian',
130 let(:params) { { :sources => {
131 'debian_unstable' => {
132 'location' => 'http://debian.mirror.iweb.ca/debian/',
133 'release' => 'unstable',
134 'repos' => 'main contrib non-free',
136 'key_server' => 'subkeys.pgp.net',
138 'include_src' => true,
141 'location' => 'http://apt.puppetlabs.com',
144 'key_server' => 'pgp.mit.edu',
149 is_expected.to contain_apt__setting('list-debian_unstable').with({
150 :ensure => 'present',
154 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$/) }
155 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$/) }
158 is_expected.to contain_apt__setting('list-puppetlabs').with({
159 :ensure => 'present',
163 it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
166 describe 'failing tests' do
167 context 'bad purge_sources_list' do
170 :purge_sources_list => 'foo'
175 is_expected.to compile
176 }.to raise_error(Puppet::Error)
180 context 'bad purge_sources_list_d' do
183 :purge_sources_list_d => 'foo'
188 is_expected.to compile
189 }.to raise_error(Puppet::Error)
193 context 'bad purge_preferences' do
196 :purge_preferences => 'foo'
201 is_expected.to compile
202 }.to raise_error(Puppet::Error)
206 context 'bad purge_preferences_d' do
209 :purge_preferences_d => 'foo'
214 is_expected.to compile
215 }.to raise_error(Puppet::Error)
219 context 'with unsupported osfamily' do
221 { :osfamily => 'Darwin', }
226 is_expected.to compile
227 }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)