]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Test fixes
authorMorgan Haskel <morgan@puppetlabs.com>
Mon, 11 Aug 2014 19:52:26 +0000 (15:52 -0400)
committerMorgan Haskel <morgan@puppetlabs.com>
Mon, 11 Aug 2014 19:52:26 +0000 (15:52 -0400)
Gemfile
spec/acceptance/apt_key_provider_spec.rb
spec/acceptance/unattended_upgrade_spec.rb

diff --git a/Gemfile b/Gemfile
index 1d8a1be527768558160b1d6c91f94232a7218b88..2d3e284cee07acbf2064e7066e15e6e10e82833f 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -3,7 +3,6 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org"
 group :development, :test do
   gem 'rake', '10.1.1',          :require => false
   gem 'rspec', '~> 2.11',        :require => false
-  gem 'pry',                     :require => false
   gem 'rspec-puppet',            :require => false
   gem 'puppetlabs_spec_helper',  :require => false
   gem 'serverspec',              :require => false
index 0a314959577c953ed7b99a8a3519de4c2986ce57..42410904daa34d4c7309c2460484d6c54e26ca6b 100644 (file)
@@ -74,7 +74,7 @@ describe 'apt_key', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily'))
 
         # Time to remove it using Puppet
         apply_manifest(pp, :catch_failures => true)
-        expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+        apply_manifest(pp, :catch_failures => true)
 
         shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}",
               :acceptable_exit_codes => [1])
@@ -176,35 +176,35 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU=
   end
 
   describe 'server =>' do
-    context 'pgp.mit.edu' do
-      it 'works' do
+    context 'nonexistant.key.server' do
+      it 'fails' do
         pp = <<-EOS
         apt_key { 'puppetlabs':
           id     => '#{PUPPETLABS_GPG_KEY_ID}',
           ensure => 'present',
-          server => 'pgp.mit.edu',
+          server => 'nonexistant.key.server',
         }
         EOS
 
-        apply_manifest(pp, :catch_failures => true)
-        expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
-        shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
+        apply_manifest(pp, :expect_failures => true) do |r|
+          expect(r.stderr).to match(/(Host not found|Couldn't resolve host)/)
+        end
       end
     end
 
-    context 'nonexistant.key.server' do
-      it 'fails' do
+    context 'pgp.mit.edu' do
+      it 'works' do
         pp = <<-EOS
         apt_key { 'puppetlabs':
           id     => '#{PUPPETLABS_GPG_KEY_ID}',
           ensure => 'present',
-          server => 'nonexistant.key.server',
+          server => 'pgp.mit.edu',
         }
         EOS
 
-        apply_manifest(pp, :expect_failures => true) do |r|
-          expect(r.stderr).to match(/(Host not found|Couldn't resolve host)/)
-        end
+        apply_manifest(pp, :catch_failures => true)
+        expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+        shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
       end
     end
   end
@@ -414,32 +414,32 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU=
 
   describe 'keyserver_options =>' do
     context 'debug' do
-      it 'works' do
+      it 'fails on invalid options' do
         pp = <<-EOS
         apt_key { 'puppetlabs':
           id                => '#{PUPPETLABS_GPG_KEY_ID}',
           ensure            => 'present',
-          keyserver_options => 'debug',
+          keyserver_options => 'this is totally bonkers',
         }
         EOS
 
-        apply_manifest(pp, :catch_failures => true)
-        expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
-        shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
+        apply_manifest(pp, :expect_failures => true) do |r|
+          expect(r.stderr).to match(/--keyserver-options this is totally/)
+        end
       end
 
-      it 'fails on invalid options' do
+      it 'works' do
         pp = <<-EOS
         apt_key { 'puppetlabs':
           id                => '#{PUPPETLABS_GPG_KEY_ID}',
           ensure            => 'present',
-          keyserver_options => 'this is totally bonkers',
+          keyserver_options => 'debug',
         }
         EOS
 
-        apply_manifest(pp, :expect_failures => true) do |r|
-          expect(r.stderr).to match(/--keyserver-options this is totally/)
-        end
+        apply_manifest(pp, :catch_failures => true)
+        expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+        shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
       end
     end
   end
index 09f4e2bed09888036c9c7f6f2b54dbfd9b6c5c85..80291248641fca03c8e19e5934add41482263e14 100644 (file)
@@ -8,10 +8,13 @@ describe 'apt::unattended_upgrades class', :unless => UNSUPPORTED_PLATFORMS.incl
       include apt::unattended_upgrades
       EOS
 
-      # Attempted workaround for problems seen on debian with
-      # something holding the package database open.
-      shell('killall -9 apt-get', { :acceptable_exit_codes => [0,1] })
-      shell('killall -9 dpkg', { :acceptable_exit_codes => [0,1] })
+      if fact('operatingsystem') == 'Debian'
+        # Attempted workaround for problems seen on debian with
+        # something holding the package database open.
+        shell('killall -9 apt-get', { :acceptable_exit_codes => [0,1] })
+        shell('killall -9 dpkg', { :acceptable_exit_codes => [0,1] })
+      end
+
       apply_manifest(pp, :catch_failures => true)
     end