Fixes to make the tests run under Debian as well as Ubuntu.

This commit is contained in:
Ashley Penney 2014-01-09 18:26:32 -05:00
parent c2f0ed219e
commit 04ca249ee0
6 changed files with 124 additions and 101 deletions

View file

@ -1,61 +1,20 @@
require 'spec_helper_acceptance' require 'spec_helper_acceptance'
describe 'apt::ppa' do if fact('operatingsystem') == 'Ubuntu'
describe 'apt::ppa' do
context 'reset' do context 'reset' do
it 'removes ppa' do it 'removes ppa' do
shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0,1,2]) shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0,1,2])
shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*', :acceptable_exit_codes => [0,1,2]) shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*', :acceptable_exit_codes => [0,1,2])
end
end
context 'adding a ppa that doesnt exist' do
it 'should work with no errors' do
pp = <<-EOS
include '::apt'
apt::ppa { 'ppa:canonical-kernel-team/ppa': }
EOS
apply_manifest(pp, :catch_failures => true)
end
describe 'contains the source file' do
it 'contains a kernel ppa source' do
shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0])
end end
end end
end
context 'readding a removed ppa.' do context 'adding a ppa that doesnt exist' do
it 'setup' do it 'should work with no errors' do
shell('add-apt-repository -y ppa:raravena80/collectd5')
# This leaves a blank file
shell('add-apt-repository --remove ppa:raravena80/collectd5')
end
it 'should readd it successfully' do
pp = <<-EOS
include '::apt'
apt::ppa { 'ppa:raravena80/collectd5': }
EOS
apply_manifest(pp, :catch_failures => true)
end
end
context 'reset' do
it 'removes added ppas' do
shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*')
shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
end
end
context 'ensure' do
context 'present' do
it 'works without failure' do
pp = <<-EOS pp = <<-EOS
include '::apt' include '::apt'
apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => present } apt::ppa { 'ppa:canonical-kernel-team/ppa': }
EOS EOS
apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true)
@ -67,72 +26,115 @@ describe 'apt::ppa' do
end end
end end
end end
end
context 'ensure' do context 'readding a removed ppa.' do
context 'absent' do it 'setup' do
it 'works without failure' do shell('add-apt-repository -y ppa:raravena80/collectd5')
# This leaves a blank file
shell('add-apt-repository --remove ppa:raravena80/collectd5')
end
it 'should readd it successfully' do
pp = <<-EOS pp = <<-EOS
include '::apt' include '::apt'
apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => absent } apt::ppa { 'ppa:raravena80/collectd5': }
EOS EOS
apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true)
end end
end
describe 'doesnt contain the source file' do context 'reset' do
it 'fails' do it 'removes added ppas' do
shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [2]) shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*')
shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
end
end
context 'ensure' do
context 'present' do
it 'works without failure' do
pp = <<-EOS
include '::apt'
apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => present }
EOS
apply_manifest(pp, :catch_failures => true)
end
describe 'contains the source file' do
it 'contains a kernel ppa source' do
shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0])
end
end end
end end
end end
end
context 'release' do context 'ensure' do
context 'precise' do context 'absent' do
it 'works without failure' do it 'works without failure' do
pp = <<-EOS pp = <<-EOS
include '::apt' include '::apt'
apt::ppa { 'ppa:canonical-kernel-team/ppa': apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => absent }
ensure => present, EOS
release => precise,
}
EOS
shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_failures => true) end
end
describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do describe 'doesnt contain the source file' do
it { should be_file } it 'fails' do
shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [2])
end
end
end end
end end
end
context 'options' do context 'release' do
context '-y' do context 'precise' do
it 'works without failure' do it 'works without failure' do
pp = <<-EOS pp = <<-EOS
include '::apt' include '::apt'
apt::ppa { 'ppa:canonical-kernel-team/ppa': apt::ppa { 'ppa:canonical-kernel-team/ppa':
ensure => present, ensure => present,
release => precise, release => precise,
options => '-y', }
} EOS
EOS
shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2])
apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true)
end end
describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do
it { should be_file } it { should be_file }
end
end end
end end
end
context 'reset' do context 'options' do
it { shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) } context '-y' do
end it 'works without failure' do
pp = <<-EOS
include '::apt'
apt::ppa { 'ppa:canonical-kernel-team/ppa':
ensure => present,
release => precise,
options => '-y',
}
EOS
shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2])
apply_manifest(pp, :catch_failures => true)
end
describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do
it { should be_file }
end
end
end
context 'reset' do
it { shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) }
end
end
end end

View file

@ -255,6 +255,7 @@ describe 'apt::source' do
apt::source { 'puppetlabs': apt::source { 'puppetlabs':
ensure => present, ensure => present,
location => 'http://apt.puppetlabs.com', location => 'http://apt.puppetlabs.com',
release => 'precise',
repos => 'main', repos => 'main',
key => '4BD6EC30', key => '4BD6EC30',
key_source => 'http://apt.puppetlabs.com/pubkey.gpg', key_source => 'http://apt.puppetlabs.com/pubkey.gpg',

View file

@ -1,5 +1,13 @@
require 'spec_helper_acceptance' require 'spec_helper_acceptance'
codename = fact('lsbdistcodename')
case fact('operatingsystem')
when 'Ubuntu'
repos = 'main universe multiverse restricted'
when 'Debian'
repos = 'main contrib non-free'
end
describe 'apt::backports class' do describe 'apt::backports class' do
context 'defaults' do context 'defaults' do
it 'should work with no errors' do it 'should work with no errors' do
@ -14,7 +22,7 @@ describe 'apt::backports class' do
context 'release' do context 'release' do
it 'should work with no errors' do it 'should work with no errors' do
pp = <<-EOS pp = <<-EOS
class { 'apt::backports': release => 'precise' } class { 'apt::backports': release => '#{codename}' }
EOS EOS
apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true)
@ -22,7 +30,7 @@ describe 'apt::backports class' do
describe file('/etc/apt/sources.list.d/backports.list') do describe file('/etc/apt/sources.list.d/backports.list') do
it { should be_file } it { should be_file }
it { should contain 'precise-backports main universe multiverse restricted' } it { should contain "#{codename}-backports #{repos}" }
end end
end end
@ -37,7 +45,7 @@ describe 'apt::backports class' do
describe file('/etc/apt/sources.list.d/backports.list') do describe file('/etc/apt/sources.list.d/backports.list') do
it { should be_file } it { should be_file }
it { should contain 'deb http://localhost/ubuntu precise-backports main universe multiverse restricted' } it { should contain "deb http://localhost/ubuntu precise-backports #{repos}" }
end end
end end

View file

@ -1,5 +1,7 @@
require 'spec_helper_acceptance' require 'spec_helper_acceptance'
codename = fact('lsbdistcodename')
describe 'apt::force define' do describe 'apt::force define' do
context 'defaults' do context 'defaults' do
it 'should work with no errors' do it 'should work with no errors' do
@ -21,12 +23,12 @@ describe 'apt::force define' do
it 'should work with no errors' do it 'should work with no errors' do
pp = <<-EOS pp = <<-EOS
include apt include apt
apt::force { 'vim': release => 'precise' } apt::force { 'vim': release => '#{codename}' }
EOS EOS
shell('apt-get remove -y vim') shell('apt-get remove -y vim')
apply_manifest(pp, :catch_failures => true) do |r| apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/apt-get -y -t precise install vim/) expect(r.stdout).to match(/apt-get -y -t #{codename} install vim/)
end end
end end
@ -57,7 +59,7 @@ describe 'apt::force define' do
it 'should work with no errors' do it 'should work with no errors' do
pp = <<-EOS pp = <<-EOS
include apt include apt
apt::force { 'tomcat7': timeout => '1' } apt::force { 'vim': timeout => '1' }
EOS EOS
shell('apt-get clean') shell('apt-get clean')

View file

@ -17,4 +17,10 @@ describe 'apt::release class' do
end end
end end
context 'reset' do
it 'cleans up' do
shell('rm -rf /etc/apt/apt.conf.d/01release')
end
end
end end

View file

@ -8,6 +8,10 @@ describe 'apt::unattended_upgrades class' do
include apt::unattended_upgrades include apt::unattended_upgrades
EOS EOS
# Attempted workaround for problems seen on debian with
# something holding the package database open.
#shell('killall -9 apt-get')
#shell('killall -9 dpkg')
apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true)
end end