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',
144 'key_server' => 'subkeys.pgp.net',
146 'include_src' => true,
149 'location' => 'http://apt.puppetlabs.com',
152 'key_server' => 'pgp.mit.edu',
157 is_expected.to contain_apt__setting('list-debian_unstable').with({
158 :ensure => 'present',
162 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$/) }
163 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$/) }
166 is_expected.to contain_apt__setting('list-puppetlabs').with({
167 :ensure => 'present',
171 it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
174 describe 'failing tests' do
175 context "purge['sources.list']=>'banana'" do
176 let(:params) { { :purge => { 'sources.list' => 'banana' }, } }
179 is_expected.to compile
180 }.to raise_error(Puppet::Error)
184 context "purge['sources.list.d']=>'banana'" do
185 let(:params) { { :purge => { 'sources.list.d' => 'banana' }, } }
188 is_expected.to compile
189 }.to raise_error(Puppet::Error)
193 context "purge['preferences']=>'banana'" do
194 let(:params) { { :purge => { 'preferences' => 'banana' }, } }
197 is_expected.to compile
198 }.to raise_error(Puppet::Error)
202 context "purge['preferences.d']=>'banana'" do
203 let(:params) { { :purge => { 'preferences.d' => 'banana' }, } }
206 is_expected.to compile
207 }.to raise_error(Puppet::Error)
211 context 'with unsupported osfamily' do
213 { :osfamily => 'Darwin', }
218 is_expected.to compile
219 }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)