From: Morgan Haskel Date: Mon, 11 Aug 2014 19:52:26 +0000 (-0400) Subject: Test fixes X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=275b0b2eac96024b508bb9dccb8e9cb51ea4e043;p=puppet-modules%2Fpuppetlabs-apt.git Test fixes --- diff --git a/Gemfile b/Gemfile index 1d8a1be..2d3e284 100644 --- 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 diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index 0a31495..4241090 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -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 diff --git a/spec/acceptance/unattended_upgrade_spec.rb b/spec/acceptance/unattended_upgrade_spec.rb index 09f4e2b..8029124 100644 --- a/spec/acceptance/unattended_upgrade_spec.rb +++ b/spec/acceptance/unattended_upgrade_spec.rb @@ -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