Skip to content

Commit

Permalink
Merge pull request #343 from mhaskel/test_fixes
Browse files Browse the repository at this point in the history
Test fixes
  • Loading branch information
Ashley Penney committed Aug 11, 2014
2 parents 96912ad + 275b0b2 commit 024a8b7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 23 additions & 23 deletions spec/acceptance/apt_key_provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

# 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])
Expand Down Expand Up @@ -176,35 +176,35 @@
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
Expand Down Expand Up @@ -414,32 +414,32 @@

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
Expand Down
11 changes: 7 additions & 4 deletions spec/acceptance/unattended_upgrade_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
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

Expand Down

0 comments on commit 024a8b7

Please sign in to comment.