describe 'apt class' do
+ context 'reset' do
+ it 'fixes the sources.list' do
+ shell('cp /etc/apt/sources.list /tmp')
+ end
+ end
+
context 'always_apt_update => true' do
it 'should work with no errors' do
pp = <<-EOS
end
end
end
+
+ context 'reset' do
+ it 'fixes the sources.list' do
+ shell('cp /tmp/sources.list /etc/apt')
+ end
+ end
+
end
it { should contain 'deb http://localhost/ubuntu precise-backports main universe multiverse restricted' }
end
end
+
+ context 'reset' do
+ it 'deletes backport files' do
+ shell('rm -rf /etc/apt/sources.list.d/backports.list')
+ shell('rm -rf /etc/apt/preferences.d/backports.pref')
+ end
+ end
+
end
apt::force { 'vim': }
EOS
+ shell('apt-get remove -y vim')
apply_manifest(pp, :catch_failures => true)
end
end
end
+ context 'release' do
+ it 'should work with no errors' do
+ pp = <<-EOS
+ include apt
+ apt::force { 'vim': release => 'precise' }
+ EOS
+
+ shell('apt-get remove -y vim')
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/apt-get -y -t precise install vim/)
+ end
+ end
+
+ describe package('vim') do
+ it { should be_installed }
+ end
+ end
+
+ context 'version' do
+ it 'should work with no errors' do
+ pp = <<-EOS
+ include apt
+ apt::force { 'vim': version => '1.1.1' }
+ EOS
+
+ shell('apt-get remove -y vim')
+ apply_manifest(pp, :catch_failures => false) do |r|
+ expect(r.stdout).to match(/apt-get -y install vim=1.1.1/)
+ end
+ end
+
+ describe package('vim') do
+ it { should_not be_installed }
+ end
+ end
+
+ context 'timeout' do
+ it 'should work with no errors' do
+ pp = <<-EOS
+ include apt
+ apt::force { 'tomcat7': timeout => '1' }
+ EOS
+
+ shell('apt-get clean')
+ apply_manifest(pp, :expect_failures => true) do |r|
+ expect(r.stderr).to match(/Error: Command exceeded timeout/)
+ end
+ end
+
+ describe package('vim') do
+ it { should_not be_installed }
+ end
+ end
+
end