]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Improve apt::force tests and ensure cleanup happens consistently.
authorAshley Penney <ashley.penney@puppetlabs.com>
Thu, 9 Jan 2014 19:26:59 +0000 (14:26 -0500)
committerAshley Penney <ashley.penney@puppetlabs.com>
Thu, 9 Jan 2014 19:26:59 +0000 (14:26 -0500)
spec/acceptance/apt_spec.rb
spec/acceptance/backports_spec.rb
spec/acceptance/force_spec.rb

index 4dbb54a0e98163b4ad9aafdeb8ec26366556ec47..5b7379fb12d8a12f34634cc86dcd7f8d16521219 100644 (file)
@@ -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
index 596be239540a07765cfe3b22e64e2a479a105f7f..ffb14ce62854b99719087368463e22348f630f55 100644 (file)
@@ -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
index 4f74ff01fd7a3b4a05aa418b1a5dc4941c27e24e..f7e374be3a29facf6da77e0f859cd732d0d5fcb7 100644 (file)
@@ -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