Add non Debian os family unsupported test.
[puppet-modules/puppetlabs-apt.git] / spec / acceptance / force_spec.rb
1 require 'spec_helper_acceptance'
2
3 codename = fact('lsbdistcodename')
4
5 describe 'apt::force define', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
6   context 'defaults' do
7     it 'should work with no errors' do
8       pp = <<-EOS
9       include apt
10       apt::force { 'vim': release => false, }
11       EOS
12
13       shell('apt-get remove -y vim')
14       apply_manifest(pp, :catch_failures => true)
15     end
16
17     describe package('vim') do
18       it { should be_installed }
19     end
20   end
21
22   context 'release' do
23     it 'should work with no errors' do
24       pp = <<-EOS
25       include apt
26       apt::force { 'vim': release => '#{codename}' }
27       EOS
28
29       shell('apt-get remove -y vim')
30       apply_manifest(pp, :catch_failures => true) do |r|
31         expect(r.stdout).to match(/apt-get -y -t #{codename} install vim/)
32       end
33     end
34
35     describe package('vim') do
36       it { should be_installed }
37     end
38   end
39
40   context 'version' do
41     it 'should work with no errors' do
42       pp = <<-EOS
43       include apt
44       apt::force { 'vim': version => '1.1.1', release => false, }
45       EOS
46
47       shell('apt-get remove -y vim')
48       apply_manifest(pp, :catch_failures => false) do |r|
49         expect(r.stdout).to match(/apt-get -y  install vim=1.1.1/)
50       end
51     end
52
53     describe package('vim') do
54       it { should_not be_installed }
55     end
56   end
57
58   context 'timeout' do
59     it 'should work with no errors' do
60       pp = <<-EOS
61       include apt
62       apt::force { 'vim': release => false, timeout => '1' }
63       EOS
64
65       shell('apt-get clean')
66       apply_manifest(pp, :expect_failures => true) do |r|
67         expect(r.stderr).to match(/Error: Command exceeded timeout/)
68       end
69     end
70
71     describe package('vim') do
72       it { should_not be_installed }
73     end
74   end
75
76 end