3c1f4385612f0b09a25a6da0d40ae6d8d8f4b2ce
[puppet-modules/puppetlabs-apt.git] / spec / classes / backports_spec.rb
1 require 'spec_helper'
2 describe 'apt::backports', :type => :class do
3
4   describe 'when asigning a custom priority to backports' do
5     let :facts do
6       {
7         'lsbdistcodename' => 'Karmic',
8         'lsbdistid'       => 'Ubuntu',
9         'osfamily'        => 'Debian'
10       }
11     end
12
13     context 'integer priority' do
14       let :params do { :pin_priority => 500 } end
15
16       it { should contain_apt__source('backports').with({
17           'location'   => 'http://old-releases.ubuntu.com/ubuntu',
18           'release'    => 'karmic-backports',
19           'repos'      => 'main universe multiverse restricted',
20           'key'        => '437D05B5',
21           'key_server' => 'pgp.mit.edu',
22         })
23       }
24
25       it { should contain_apt__pin('backports').with({
26           'release'  => 'karmic-backports',
27           'priority' => 500,
28         })
29       }
30     end
31
32     context 'invalid priority' do
33       let :params do { :pin_priority => 'banana' } end
34       it 'should fail' do
35         expect { subject }.to raise_error(/must be an integer/)
36       end
37     end
38   end
39
40   describe 'when turning on backports for ubuntu karmic' do
41
42     let :facts do
43       {
44         'lsbdistcodename' => 'Karmic',
45         'lsbdistid'       => 'Ubuntu',
46         'osfamily'        => 'Debian'
47       }
48     end
49
50     it { should contain_apt__source('backports').with({
51         'location'   => 'http://old-releases.ubuntu.com/ubuntu',
52         'release'    => 'karmic-backports',
53         'repos'      => 'main universe multiverse restricted',
54         'key'        => '437D05B5',
55         'key_server' => 'pgp.mit.edu',
56       })
57     }
58
59     it { should contain_apt__pin('backports').with({
60         'release'  => 'karmic-backports',
61         'priority' => 200,
62       })
63     }
64   end
65
66   describe "when turning on backports for debian squeeze" do
67
68     let :facts do
69       {
70         'lsbdistcodename' => 'Squeeze',
71         'lsbdistid'       => 'Debian',
72         'osfamily'        => 'Debian'
73       }
74     end
75
76     it { should contain_apt__source('backports').with({
77         'location'   => 'http://backports.debian.org/debian-backports',
78         'release'    => 'squeeze-backports',
79         'repos'      => 'main contrib non-free',
80         'key'        => '46925553',
81         'key_server' => 'pgp.mit.edu',
82       })
83     }
84
85     it { should contain_apt__pin('backports').with({
86         'release'  => 'squeeze-backports',
87         'priority' => 200,
88       })
89     }
90   end
91
92   describe "when turning on backports for linux mint debian edition" do
93
94     let :facts do
95       {
96         'lsbdistcodename' => 'debian',
97         'lsbdistid'       => 'LinuxMint',
98         'osfamily'        => 'Debian'
99       }
100     end
101
102     it { should contain_apt__source('backports').with({
103         'location'   => 'http://ftp.debian.org/debian/',
104         'release'    => 'wheezy-backports',
105         'repos'      => 'main contrib non-free',
106         'key'        => '46925553',
107         'key_server' => 'pgp.mit.edu',
108       })
109     }
110
111     it { should contain_apt__pin('backports').with({
112         'release'  => 'wheezy-backports',
113         'priority' => 200,
114       })
115     }
116   end
117
118   describe "when turning on backports for linux mint 17 (ubuntu-based)" do
119
120     let :facts do
121       {
122         'lsbdistcodename' => 'qiana',
123         'lsbdistid'       => 'LinuxMint',
124         'osfamily'        => 'Debian'
125       }
126     end
127
128     it { should contain_apt__source('backports').with({
129         'location'   => 'http://us.archive.ubuntu.com/ubuntu',
130         'release'    => 'trusty-backports',
131         'repos'      => 'main universe multiverse restricted',
132         'key'        => '437D05B5',
133         'key_server' => 'pgp.mit.edu',
134       })
135     }
136
137     it { should contain_apt__pin('backports').with({
138         'release'  => 'trusty-backports',
139         'priority' => 200,
140       })
141     }
142   end
143
144   describe "when turning on backports for debian squeeze but using your own mirror" do
145
146     let :facts do
147       {
148         'lsbdistcodename' => 'Squeeze',
149         'lsbdistid'       => 'Debian',
150         'osfamily'        => 'Debian'
151       }
152     end
153
154     let :location do
155       'http://mirrors.example.com/debian-backports'
156     end
157
158     let :params do
159       { 'location' => location }
160     end
161
162     it { should contain_apt__source('backports').with({
163         'location'   => location,
164         'release'    => 'squeeze-backports',
165         'repos'      => 'main contrib non-free',
166         'key'        => '46925553',
167         'key_server' => 'pgp.mit.edu',
168       })
169     }
170
171     it { should contain_apt__pin('backports').with({
172         'release'  => 'squeeze-backports',
173         'priority' => 200,
174       })
175     }
176   end
177 end