Add non Debian os family unsupported test.
[puppet-modules/puppetlabs-apt.git] / spec / acceptance / apt_ppa_spec.rb
1 require 'spec_helper_acceptance'
2
3 if fact('operatingsystem') == 'Ubuntu'
4   describe 'apt::ppa', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
5
6     context 'reset' do
7       it 'removes ppa' do
8         shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0,1,2])
9         shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*', :acceptable_exit_codes => [0,1,2])
10       end
11     end
12
13     context 'adding a ppa that doesnt exist' do
14       it 'should work with no errors' do
15         pp = <<-EOS
16         include '::apt'
17         apt::ppa { 'ppa:canonical-kernel-team/ppa': }
18         EOS
19
20         apply_manifest(pp, :catch_failures => true)
21       end
22
23       describe 'contains the source file' do
24         it 'contains a kernel ppa source' do
25           shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0])
26         end
27       end
28     end
29
30     context 'reading a removed ppa.' do
31       it 'setup' do
32         # This leaves a blank file
33         shell('echo > /etc/apt/sources.list.d/raravena80-collectd5-$(lsb_release -c -s).list')
34       end
35
36       it 'should read it successfully' do
37         pp = <<-EOS
38         include '::apt'
39         apt::ppa { 'ppa:raravena80/collectd5': }
40         EOS
41
42         apply_manifest(pp, :catch_failures => true)
43       end
44     end
45
46     context 'reset' do
47       it 'removes added ppas' do
48         shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*')
49         shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
50       end
51     end
52
53     context 'release' do
54       context 'precise' do
55         it 'works without failure' do
56           pp = <<-EOS
57           include '::apt'
58           apt::ppa { 'ppa:canonical-kernel-team/ppa':
59             release => precise,
60           }
61           EOS
62
63           shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2])
64           apply_manifest(pp, :catch_failures => true)
65         end
66
67         describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do
68           it { should be_file }
69         end
70       end
71     end
72
73     context 'options' do
74       context '-y', :unless => default[:platform].match(/10\.04/) do
75         it 'works without failure' do
76           pp = <<-EOS
77           include '::apt'
78           apt::ppa { 'ppa:canonical-kernel-team/ppa':
79             release => precise,
80             options => '-y',
81           }
82           EOS
83
84           shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2])
85           apply_manifest(pp, :catch_failures => true)
86         end
87
88         describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do
89           it { should be_file }
90         end
91       end
92     end
93
94     context 'reset' do
95       it { shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) }
96     end
97   end
98 end