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'
describe 'apt::ppa' do
if fact('operatingsystem') == 'Ubuntu'
describe 'apt::ppa' do
context 'reset' 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/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])
context 'reset' 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/raravena80-collectd5-*', :acceptable_exit_codes => [0,1,2])
end
end
end
context 'readding a removed ppa.' do
it 'setup' 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
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': ensure => present }
apt::ppa { 'ppa:canonical-kernel-team/ppa': }
EOS
apply_manifest(pp, :catch_failures => true)
@ -67,72 +26,115 @@ describe 'apt::ppa' do
end
end
end
end
context 'ensure' do
context 'absent' do
it 'works without failure' do
context 'readding a removed ppa.' do
it 'setup' 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:canonical-kernel-team/ppa': ensure => absent }
apt::ppa { 'ppa:raravena80/collectd5': }
EOS
apply_manifest(pp, :catch_failures => true)
end
end
describe 'doesnt contain the source file' do
it 'fails' do
shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [2])
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
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
context 'release' do
context 'precise' do
it 'works without failure' do
pp = <<-EOS
include '::apt'
apt::ppa { 'ppa:canonical-kernel-team/ppa':
ensure => present,
release => precise,
}
EOS
context 'ensure' do
context 'absent' do
it 'works without failure' do
pp = <<-EOS
include '::apt'
apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => absent }
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
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 }
describe 'doesnt contain the source file' do
it 'fails' do
shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [2])
end
end
end
end
end
context 'options' do
context '-y' do
it 'works without failure' do
pp = <<-EOS
include '::apt'
apt::ppa { 'ppa:canonical-kernel-team/ppa':
ensure => present,
release => precise,
options => '-y',
}
EOS
context 'release' do
context 'precise' do
it 'works without failure' do
pp = <<-EOS
include '::apt'
apt::ppa { 'ppa:canonical-kernel-team/ppa':
ensure => present,
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)
end
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 }
describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do
it { should be_file }
end
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
context 'options' do
context '-y' do
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

View file

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

View file

@ -1,5 +1,13 @@
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
context 'defaults' do
it 'should work with no errors' do
@ -14,7 +22,7 @@ describe 'apt::backports class' do
context 'release' do
it 'should work with no errors' do
pp = <<-EOS
class { 'apt::backports': release => 'precise' }
class { 'apt::backports': release => '#{codename}' }
EOS
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
it { should be_file }
it { should contain 'precise-backports main universe multiverse restricted' }
it { should contain "#{codename}-backports #{repos}" }
end
end
@ -37,7 +45,7 @@ describe 'apt::backports class' do
describe file('/etc/apt/sources.list.d/backports.list') do
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

View file

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

View file

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

View file

@ -8,6 +8,10 @@ describe 'apt::unattended_upgrades class' do
include apt::unattended_upgrades
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)
end