Add non Debian os family unsupported test.
[puppet-modules/puppetlabs-apt.git] / spec / acceptance / pin_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'apt::pin define', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
4   context 'defaults' do
5     it 'should work with no errors' do
6       pp = <<-EOS
7       include apt
8       apt::pin { 'vim-puppet': }
9       EOS
10
11       apply_manifest(pp, :catch_failures => true)
12     end
13
14     describe file('/etc/apt/preferences.d/vim-puppet.pref') do
15       it { should be_file }
16       it { should contain 'Pin: release a=vim-puppet' }
17     end
18   end
19
20   context 'ensure' do
21     context 'present' do
22       it 'should work with no errors' do
23         pp = <<-EOS
24         include apt
25         apt::pin { 'vim-puppet': ensure => present }
26         EOS
27
28         apply_manifest(pp, :catch_failures => true)
29       end
30
31       describe file('/etc/apt/preferences.d/vim-puppet.pref') do
32         it { should be_file }
33         it { should contain 'Pin: release a=vim-puppet' }
34       end
35     end
36
37     context 'absent' do
38       it 'should work with no errors' do
39         pp = <<-EOS
40         include apt
41         apt::pin { 'vim-puppet': ensure => absent }
42         EOS
43
44         apply_manifest(pp, :catch_failures => true)
45       end
46
47       describe file('/etc/apt/preferences.d/vim-puppet.pref') do
48         it { should_not be_file }
49       end
50     end
51   end
52
53   context 'order' do
54     context '99' do
55       it 'should work with no errors' do
56         pp = <<-EOS
57         include apt
58         apt::pin { 'vim-puppet':
59           ensure => present,
60           order  => '99',
61         }
62         EOS
63
64         apply_manifest(pp, :catch_failures => true)
65       end
66
67       describe file('/etc/apt/preferences.d/99-vim-puppet.pref') do
68         it { should be_file }
69         it { should contain 'Pin: release a=vim-puppet' }
70       end
71     end
72   end
73
74   context 'packages' do
75     context 'test' do
76       it 'should work with no errors' do
77         pp = <<-EOS
78         include apt
79         apt::pin { 'vim-puppet':
80           ensure   => present,
81           packages => 'test',
82         }
83         EOS
84
85         apply_manifest(pp, :catch_failures => true)
86       end
87
88       describe file('/etc/apt/preferences.d/vim-puppet.pref') do
89         it { should be_file }
90         it { should contain 'Package: test' }
91         it { should contain 'Pin: release a=vim-puppet' }
92       end
93     end
94   end
95
96   context 'release' do
97     context 'testrelease' do
98       it 'should work with no errors' do
99         pp = <<-EOS
100         include apt
101         apt::pin { 'vim-puppet':
102           ensure  => present,
103           release => 'testrelease',
104         }
105         EOS
106
107         apply_manifest(pp, :catch_failures => true)
108       end
109
110       describe file('/etc/apt/preferences.d/vim-puppet.pref') do
111         it { should be_file }
112         it { should contain 'Pin: release a=testrelease' }
113       end
114     end
115   end
116
117   context 'origin' do
118     context 'testrelease' do
119       it 'should work with no errors' do
120         pp = <<-EOS
121         include apt
122         apt::pin { 'vim-puppet':
123           ensure  => present,
124           origin  => 'testrelease',
125         }
126         EOS
127
128         apply_manifest(pp, :catch_failures => true)
129       end
130
131       describe file('/etc/apt/preferences.d/vim-puppet.pref') do
132         it { should be_file }
133         it { should contain 'Pin: origin "testrelease"' }
134       end
135     end
136   end
137
138   context 'version' do
139     context '1.0.0' do
140       it 'should work with no errors' do
141         pp = <<-EOS
142         include apt
143         apt::pin { 'vim-puppet':
144           ensure   => present,
145           packages => 'test',
146           version  => '1.0.0',
147         }
148         EOS
149
150         apply_manifest(pp, :catch_failures => true)
151       end
152
153       describe file('/etc/apt/preferences.d/vim-puppet.pref') do
154         it { should be_file }
155         it { should contain 'Package: test' }
156         it { should contain 'Pin: version 1.0.0' }
157       end
158     end
159   end
160
161   context 'codename' do
162     context 'testname' do
163       it 'should work with no errors' do
164         pp = <<-EOS
165         include apt
166         apt::pin { 'vim-puppet':
167           ensure   => present,
168           codename => 'testname',
169         }
170         EOS
171
172         apply_manifest(pp, :catch_failures => true)
173       end
174
175       describe file('/etc/apt/preferences.d/vim-puppet.pref') do
176         it { should be_file }
177         it { should contain 'Pin: release n=testname' }
178       end
179     end
180   end
181
182   context 'release_version' do
183     context '1.1.1' do
184       it 'should work with no errors' do
185         pp = <<-EOS
186         include apt
187         apt::pin { 'vim-puppet':
188           ensure          => present,
189           release_version => '1.1.1',
190         }
191         EOS
192
193         apply_manifest(pp, :catch_failures => true)
194       end
195
196       describe file('/etc/apt/preferences.d/vim-puppet.pref') do
197         it { should be_file }
198         it { should contain 'Pin: release v=1.1.1' }
199       end
200     end
201   end
202
203   context 'component' do
204     context 'testcomponent' do
205       it 'should work with no errors' do
206         pp = <<-EOS
207         include apt
208         apt::pin { 'vim-puppet':
209           ensure    => present,
210           component => 'testcomponent',
211         }
212         EOS
213
214         apply_manifest(pp, :catch_failures => true)
215       end
216
217       describe file('/etc/apt/preferences.d/vim-puppet.pref') do
218         it { should be_file }
219         it { should contain 'Pin: release c=testcomponent' }
220       end
221     end
222   end
223
224   context 'originator' do
225     context 'testorigin' do
226       it 'should work with no errors' do
227         pp = <<-EOS
228         include apt
229         apt::pin { 'vim-puppet':
230           ensure     => present,
231           originator => 'testorigin',
232         }
233         EOS
234
235         apply_manifest(pp, :catch_failures => true)
236       end
237
238       describe file('/etc/apt/preferences.d/vim-puppet.pref') do
239         it { should be_file }
240         it { should contain 'Pin: release o=testorigin' }
241       end
242     end
243   end
244
245   context 'label' do
246     context 'testlabel' do
247       it 'should work with no errors' do
248         pp = <<-EOS
249         include apt
250         apt::pin { 'vim-puppet':
251           ensure => present,
252           label  => 'testlabel',
253         }
254         EOS
255
256         apply_manifest(pp, :catch_failures => true)
257       end
258
259       describe file('/etc/apt/preferences.d/vim-puppet.pref') do
260         it { should be_file }
261         it { should contain 'Pin: release l=testlabel' }
262       end
263     end
264   end
265
266 end