From c2f0ed219e23ccc3faaf2512082240102921e4a9 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Thu, 9 Jan 2014 14:26:59 -0500 Subject: [PATCH] Improve apt::force tests and ensure cleanup happens consistently. --- spec/acceptance/apt_spec.rb | 13 ++++++++ spec/acceptance/backports_spec.rb | 8 +++++ spec/acceptance/force_spec.rb | 55 +++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index 4dbb54a..5b7379f 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -2,6 +2,12 @@ require 'spec_helper_acceptance' 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 @@ -217,4 +223,11 @@ describe 'apt class' do end end end + + context 'reset' do + it 'fixes the sources.list' do + shell('cp /tmp/sources.list /etc/apt') + end + end + end diff --git a/spec/acceptance/backports_spec.rb b/spec/acceptance/backports_spec.rb index 596be23..ffb14ce 100644 --- a/spec/acceptance/backports_spec.rb +++ b/spec/acceptance/backports_spec.rb @@ -40,4 +40,12 @@ describe 'apt::backports class' do 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 diff --git a/spec/acceptance/force_spec.rb b/spec/acceptance/force_spec.rb index 4f74ff0..f7e374b 100644 --- a/spec/acceptance/force_spec.rb +++ b/spec/acceptance/force_spec.rb @@ -8,6 +8,7 @@ describe 'apt::force define' do apt::force { 'vim': } EOS + shell('apt-get remove -y vim') apply_manifest(pp, :catch_failures => true) end @@ -16,4 +17,58 @@ describe 'apt::force define' do 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 -- 2.45.2