1 require 'spec_helper_acceptance'
3 describe 'apt class' do
5 context 'always_apt_update => true' do
6 it 'should work with no errors' do
8 class { 'apt': always_apt_update => true }
11 apply_manifest(pp, :catch_failures => true) do |r|
12 expect(r.stdout).to match(/apt_update/)
16 context 'always_apt_update => false' do
17 it 'should work with no errors' do
19 class { 'apt': always_apt_update => false }
22 apply_manifest(pp, :catch_failures => true) do |r|
23 expect(r.stdout).to_not match(/apt_update/)
28 # disable_keys drops in a 99unauth file to ignore keys in
30 context 'disable_keys => true' do
31 it 'should work with no errors' do
33 class { 'apt': disable_keys => true }
36 apply_manifest(pp, :catch_failures => true)
39 describe file('/etc/apt/apt.conf.d/99unauth') do
41 it { should contain 'APT::Get::AllowUnauthenticated 1;' }
44 context 'disable_keys => false' do
45 it 'should work with no errors' do
47 class { 'apt': disable_keys => false }
50 apply_manifest(pp, :catch_failures => true)
53 describe file('/etc/apt/apt.conf.d/99unauth') do
54 it { should_not be_file }
58 # proxy_host sets the proxy to use for transfers.
59 # proxy_port sets the proxy port to use.
60 context 'proxy settings' do
61 it 'should work with no errors' do
64 proxy_host => 'localhost',
69 apply_manifest(pp, :catch_failures => true)
72 describe file('/etc/apt/apt.conf.d/proxy') do
74 it { should contain 'Acquire::http::Proxy "http://localhost:8080\";' }
78 context 'purge_sources' do
79 it 'creates a fake apt file' do
80 shell('touch /etc/apt/sources.list.d/fake.list')
81 shell('echo "deb fake" >> /etc/apt/sources.list')
83 it 'purge_sources_list and purge_sources_list_d => true' do
86 purge_sources_list => true,
87 purge_sources_list_d => true,
91 apply_manifest(pp, :catch_failures => true)
94 describe file('/etc/apt/sources.list') do
95 it { should_not contain 'deb fake' }
98 describe file('/etc/apt/sources.list.d/fake.list') do
99 it { should_not be_file }
102 context 'proxy settings' do
103 it 'should work with no errors' do
106 proxy_host => 'localhost',
107 proxy_port => '8080',
111 apply_manifest(pp, :catch_failures => true)
114 describe file('/etc/apt/apt.conf.d/proxy') do
115 it { should be_file }
116 it { should contain 'Acquire::http::Proxy "http://localhost:8080\";' }
120 context 'purge_sources' do
122 it 'creates a fake apt file' do
123 shell('touch /etc/apt/sources.list.d/fake.list')
124 shell('echo "deb fake" >> /etc/apt/sources.list')
126 it 'purge_sources_list and purge_sources_list_d => false' do
129 purge_sources_list => false,
130 purge_sources_list_d => false,
134 apply_manifest(pp, :catch_failures => false)
137 describe file('/etc/apt/sources.list') do
138 it { should contain 'deb fake' }
141 describe file('/etc/apt/sources.list.d/fake.list') do
142 it { should be_file }
147 it 'creates a fake apt file' do
148 shell('touch /etc/apt/sources.list.d/fake.list')
149 shell('echo "deb fake" >> /etc/apt/sources.list')
151 it 'purge_sources_list and purge_sources_list_d => true' do
154 purge_sources_list => true,
155 purge_sources_list_d => true,
159 apply_manifest(pp, :catch_failures => true)
162 describe file('/etc/apt/sources.list') do
163 it { should_not contain 'deb fake' }
166 describe file('/etc/apt/sources.list.d/fake.list') do
167 it { should_not be_file }
172 context 'purge_preferences_d' do
174 it 'creates a preferences file' do
175 shell('touch /etc/apt/preferences.d/test')
178 it 'should work with no errors' do
180 class { 'apt': purge_preferences_d => false }
183 apply_manifest(pp, :catch_failures => true)
186 describe file('/etc/apt/preferences.d/test') do
187 it { should be_file }
191 it 'creates a preferences file' do
192 shell('touch /etc/apt/preferences.d/test')
195 it 'should work with no errors' do
197 class { 'apt': purge_preferences_d => true }
200 apply_manifest(pp, :catch_failures => true)
203 describe file('/etc/apt/preferences.d/test') do
204 it { should_not be_file }
209 context 'update_timeout' do
211 it 'should work with no errors' do
213 class { 'apt': update_timeout => '5000' }
216 apply_manifest(pp, :catch_failures => true)