1 require 'spec_helper_acceptance'
3 describe 'apt class' do
6 it 'fixes the sources.list' do
7 shell('cp /etc/apt/sources.list /tmp')
11 context 'always_apt_update => true' do
12 it 'should work with no errors' do
14 class { 'apt': always_apt_update => true }
17 apply_manifest(pp, :catch_failures => true) do |r|
18 expect(r.stdout).to match(/apt_update/)
22 context 'always_apt_update => false' do
23 it 'should work with no errors' do
25 class { 'apt': always_apt_update => false }
28 apply_manifest(pp, :catch_failures => true) do |r|
29 expect(r.stdout).to_not match(/apt_update/)
34 # disable_keys drops in a 99unauth file to ignore keys in
36 context 'disable_keys => true' do
37 it 'should work with no errors' do
39 class { 'apt': disable_keys => true }
42 apply_manifest(pp, :catch_failures => true)
45 describe file('/etc/apt/apt.conf.d/99unauth') do
47 it { should contain 'APT::Get::AllowUnauthenticated 1;' }
50 context 'disable_keys => false' do
51 it 'should work with no errors' do
53 class { 'apt': disable_keys => false }
56 apply_manifest(pp, :catch_failures => true)
59 describe file('/etc/apt/apt.conf.d/99unauth') do
60 it { should_not be_file }
64 # proxy_host sets the proxy to use for transfers.
65 # proxy_port sets the proxy port to use.
66 context 'proxy settings' do
67 it 'should work with no errors' do
70 proxy_host => 'localhost',
75 apply_manifest(pp, :catch_failures => true)
78 describe file('/etc/apt/apt.conf.d/proxy') do
80 it { should contain 'Acquire::http::Proxy "http://localhost:7042\";' }
84 context 'purge_sources' do
85 it 'creates a fake apt file' do
86 shell('touch /etc/apt/sources.list.d/fake.list')
87 shell('echo "deb fake" >> /etc/apt/sources.list')
89 it 'purge_sources_list and purge_sources_list_d => true' do
92 purge_sources_list => true,
93 purge_sources_list_d => true,
97 apply_manifest(pp, :catch_failures => true)
100 describe file('/etc/apt/sources.list') do
101 it { should_not contain 'deb fake' }
104 describe file('/etc/apt/sources.list.d/fake.list') do
105 it { should_not be_file }
108 context 'proxy settings' do
109 it 'should work with no errors' do
112 proxy_host => 'localhost',
113 proxy_port => '7042',
117 apply_manifest(pp, :catch_failures => true)
120 describe file('/etc/apt/apt.conf.d/proxy') do
121 it { should be_file }
122 it { should contain 'Acquire::http::Proxy "http://localhost:7042\";' }
126 context 'purge_sources' do
128 it 'creates a fake apt file' do
129 shell('touch /etc/apt/sources.list.d/fake.list')
130 shell('echo "deb fake" >> /etc/apt/sources.list')
132 it 'purge_sources_list and purge_sources_list_d => false' do
135 purge_sources_list => false,
136 purge_sources_list_d => false,
140 apply_manifest(pp, :catch_failures => false)
143 describe file('/etc/apt/sources.list') do
144 it { should contain 'deb fake' }
147 describe file('/etc/apt/sources.list.d/fake.list') do
148 it { should be_file }
153 it 'creates a fake apt file' do
154 shell('touch /etc/apt/sources.list.d/fake.list')
155 shell('echo "deb fake" >> /etc/apt/sources.list')
157 it 'purge_sources_list and purge_sources_list_d => true' do
160 purge_sources_list => true,
161 purge_sources_list_d => true,
165 apply_manifest(pp, :catch_failures => true)
168 describe file('/etc/apt/sources.list') do
169 it { should_not contain 'deb fake' }
172 describe file('/etc/apt/sources.list.d/fake.list') do
173 it { should_not be_file }
178 context 'purge_preferences_d' do
180 it 'creates a preferences file' do
181 shell('touch /etc/apt/preferences.d/test')
184 it 'should work with no errors' do
186 class { 'apt': purge_preferences_d => false }
189 apply_manifest(pp, :catch_failures => true)
192 describe file('/etc/apt/preferences.d/test') do
193 it { should be_file }
197 it 'creates a preferences file' do
198 shell('touch /etc/apt/preferences.d/test')
201 it 'should work with no errors' do
203 class { 'apt': purge_preferences_d => true }
206 apply_manifest(pp, :catch_failures => true)
209 describe file('/etc/apt/preferences.d/test') do
210 it { should_not be_file }
215 context 'update_timeout' do
217 it 'should work with no errors' do
219 class { 'apt': update_timeout => '5000' }
222 apply_manifest(pp, :catch_failures => true)
228 it 'fixes the sources.list' do
229 shell('cp /tmp/sources.list /etc/apt')