Adding dash to key_server validate regex
[puppet-modules/puppetlabs-apt.git] / spec / acceptance / backports_spec.rb
1 require 'spec_helper_acceptance'
2
3 codename = fact('lsbdistcodename')
4 case fact('operatingsystem')
5 when 'Ubuntu'
6   repos = 'main universe multiverse restricted'
7 when 'Debian'
8   repos = 'main contrib non-free'
9 end
10
11 describe 'apt::backports class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
12   context 'defaults' do
13     it 'should work with no errors' do
14       pp = <<-EOS
15       class { 'apt::backports': }
16       EOS
17
18       apply_manifest(pp, :catch_failures => true)
19     end
20   end
21
22   context 'release' do
23     it 'should work with no errors' do
24       pp = <<-EOS
25       class { 'apt::backports': release => '#{codename}' }
26       EOS
27
28       apply_manifest(pp, :catch_failures => true)
29     end
30
31     describe file('/etc/apt/sources.list.d/backports.list') do
32       it { should be_file }
33       it { should contain "#{codename}-backports #{repos}" }
34     end
35   end
36
37   context 'location' do
38     it 'should work with no errors' do
39       pp = <<-EOS
40       class { 'apt::backports': release => 'precise', location => 'http://localhost/ubuntu' }
41       EOS
42
43       apply_manifest(pp, :catch_failures => true)
44     end
45
46     describe file('/etc/apt/sources.list.d/backports.list') do
47       it { should be_file }
48       it { should contain "deb http://localhost/ubuntu precise-backports #{repos}" }
49     end
50   end
51
52   context 'pin_priority' do
53     it 'should work with no errors' do
54       pp = <<-EOS
55       class { 'apt::backports': pin_priority => 500, }
56       EOS
57
58       apply_manifest(pp, :catch_failures => true)
59     end
60     describe file('/etc/apt/preferences.d/backports.pref') do
61       it { should be_file }
62       it { should contain "Pin-Priority: 500" }
63     end
64   end
65
66   context 'reset' do
67     it 'deletes backport files' do
68       shell('rm -rf /etc/apt/sources.list.d/backports.list')
69       shell('rm -rf /etc/apt/preferences.d/backports.pref')
70     end
71   end
72
73 end