2014-01-07 01:53:19 +01:00
|
|
|
require 'spec_helper_acceptance'
|
|
|
|
|
2014-01-10 00:26:32 +01:00
|
|
|
codename = fact('lsbdistcodename')
|
|
|
|
|
2014-02-24 22:52:13 +01:00
|
|
|
describe 'apt::force define', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
|
2014-01-07 01:53:19 +01:00
|
|
|
context 'defaults' do
|
|
|
|
it 'should work with no errors' do
|
|
|
|
pp = <<-EOS
|
|
|
|
include apt
|
2014-02-14 23:49:43 +01:00
|
|
|
apt::force { 'vim': }
|
2014-01-07 01:53:19 +01:00
|
|
|
EOS
|
|
|
|
|
2014-01-09 20:26:59 +01:00
|
|
|
shell('apt-get remove -y vim')
|
2014-01-07 01:53:19 +01:00
|
|
|
apply_manifest(pp, :catch_failures => true)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe package('vim') do
|
|
|
|
it { should be_installed }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-01-09 20:26:59 +01:00
|
|
|
context 'release' do
|
|
|
|
it 'should work with no errors' do
|
|
|
|
pp = <<-EOS
|
|
|
|
include apt
|
2014-01-10 00:26:32 +01:00
|
|
|
apt::force { 'vim': release => '#{codename}' }
|
2014-01-09 20:26:59 +01:00
|
|
|
EOS
|
|
|
|
|
|
|
|
shell('apt-get remove -y vim')
|
|
|
|
apply_manifest(pp, :catch_failures => true) do |r|
|
2014-01-10 00:26:32 +01:00
|
|
|
expect(r.stdout).to match(/apt-get -y -t #{codename} install vim/)
|
2014-01-09 20:26:59 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe package('vim') do
|
|
|
|
it { should be_installed }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'version' do
|
|
|
|
it 'should work with no errors' do
|
|
|
|
pp = <<-EOS
|
|
|
|
include apt
|
2014-02-14 23:49:43 +01:00
|
|
|
apt::force { 'vim': version => '1.1.1' }
|
2014-01-09 20:26:59 +01:00
|
|
|
EOS
|
|
|
|
|
|
|
|
shell('apt-get remove -y vim')
|
|
|
|
apply_manifest(pp, :catch_failures => false) do |r|
|
|
|
|
expect(r.stdout).to match(/apt-get -y install vim=1.1.1/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe package('vim') do
|
|
|
|
it { should_not be_installed }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'timeout' do
|
|
|
|
it 'should work with no errors' do
|
|
|
|
pp = <<-EOS
|
|
|
|
include apt
|
2014-02-14 23:49:43 +01:00
|
|
|
apt::force { 'vim': timeout => '1' }
|
2014-01-09 20:26:59 +01:00
|
|
|
EOS
|
|
|
|
|
|
|
|
shell('apt-get clean')
|
|
|
|
apply_manifest(pp, :expect_failures => true) do |r|
|
|
|
|
expect(r.stderr).to match(/Error: Command exceeded timeout/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe package('vim') do
|
|
|
|
it { should_not be_installed }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-01-07 01:53:19 +01:00
|
|
|
end
|