This repository has been archived by the owner on Feb 13, 2020. It is now read-only.
forked from voxpupuli/puppet-r10k
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_spec.rb
333 lines (305 loc) · 9.48 KB
/
install_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
require 'spec_helper'
version = '2.0.0'
describe 'r10k::install', type: :class do
on_supported_os.each do |os, facts|
context "on #{os} " do
let :facts do
facts
end
context 'with gem provider' do
let :params do
{
install_options: '',
keywords: '',
manage_ruby_dependency: 'declare',
package_name: 'r10k',
provider: 'gem',
version: version,
puppet_master: true
}
end
it { is_expected.to contain_class('git') }
# New versions of this gem do not require these packages
it { is_expected.not_to contain_class('make') }
it { is_expected.not_to contain_package('gcc') }
it { is_expected.to contain_class('r10k::install::gem').with(version: version) }
it do
is_expected.to contain_package('r10k').with(
ensure: version,
provider: 'gem'
)
end
end
context 'with gem with empty install_options' do
let :params do
{
manage_ruby_dependency: 'include',
package_name: 'r10k',
provider: 'gem',
version: version,
keywords: '',
install_options: [],
puppet_master: true
}
end
it do
is_expected.to contain_package('r10k').with(
ensure: version,
provider: 'gem',
install_options: ['--no-ri', '--no-rdoc']
)
end
end
context 'with gem with populated install_options' do
let :params do
{
manage_ruby_dependency: 'include',
package_name: 'r10k',
provider: 'gem',
version: version,
keywords: '',
install_options: ['BOGON'],
puppet_master: true
}
end
it do
is_expected.to contain_package('r10k').with(
ensure: version,
provider: 'gem',
install_options: ['BOGON']
)
end
end
context 'with puppet_gem provider' do
let :params do
{
package_name: 'r10k',
version: version,
provider: 'puppet_gem',
keywords: '',
manage_ruby_dependency: 'declare',
install_options: ''
}
end
it { is_expected.to contain_class('git') }
it { is_expected.to contain_class('r10k::install::puppet_gem') }
it do
is_expected.to contain_package('r10k').with(
ensure: version,
provider: 'puppet_gem'
)
end
end
context 'with puppet_gem on Puppet FOSS 4.2.1' do
let :params do
{
manage_ruby_dependency: 'declare',
install_options: '',
package_name: 'r10k',
provider: 'puppet_gem',
version: version,
keywords: ''
}
end
let :facts do
facts.merge(
puppetversion: '4.2.1'
)
end
it do
is_expected.to contain_package('r10k').with(
ensure: version,
provider: 'puppet_gem'
)
end
it do
is_expected.to contain_file('/usr/bin/r10k').with(
ensure: 'link',
target: '/opt/puppetlabs/puppet/bin/r10k',
require: 'Package[r10k]'
)
end
end
context 'with pe_gem provider' do
let :params do
{
package_name: 'r10k',
version: version,
provider: 'pe_gem',
keywords: '',
manage_ruby_dependency: 'declare',
install_options: '',
puppet_master: true
}
end
let :facts do
facts.merge(
puppetversion: '4.8.0',
pe_version: '2016.4.0'
)
end
it { is_expected.to contain_class('git') }
it { is_expected.to contain_class('r10k::install::pe_gem') }
it do
is_expected.to contain_package('r10k').with(
ensure: version,
provider: 'pe_gem'
)
end
end
context 'with pe_gem with PE 3.8' do
let :params do
{
manage_ruby_dependency: 'declare',
install_options: '',
package_name: 'r10k',
provider: 'pe_gem',
version: version,
keywords: '',
puppet_master: true
}
end
let :facts do
facts.merge(
is_pe: true,
pe_version: '3.8.0'
)
end
it { is_expected.to contain_class('r10k::params') }
it do
is_expected.to contain_package('r10k').with(
ensure: version,
provider: 'pe_gem'
)
end
it { is_expected.not_to contain_file('/usr/bin/r10k') }
end
context 'with pe_gem with PE 3.8.1 and not a master' do
let :params do
{
manage_ruby_dependency: 'declare',
install_options: '',
package_name: 'r10k',
provider: 'pe_gem',
version: version,
keywords: '',
puppet_master: false
}
end
let :facts do
facts.merge(
is_pe: true,
pe_version: '3.8.1'
)
end
it do
is_expected.to contain_package('r10k').with(
ensure: version,
provider: 'pe_gem'
)
end
it do
is_expected.to contain_file('/usr/bin/r10k').with(
ensure: 'link',
target: '/opt/puppet/bin/r10k',
require: 'Package[r10k]'
)
end
end
context 'with bundle provider' do
let :params do
{
package_name: 'r10k',
version: version,
provider: 'bundle',
manage_ruby_dependency: 'declare',
keywords: '',
install_options: '',
puppet_master: true
}
end
it { is_expected.to contain_class('git') }
it { is_expected.to contain_class('r10k::install::bundle') }
it { is_expected.not_to contain_package('r10k') }
end
context 'with yum provider' do
let :params do
{
install_options: '',
keywords: '',
manage_ruby_dependency: 'declare',
package_name: 'rubygem-r10k',
provider: 'yum',
version: 'latest',
puppet_master: true
}
end
it { is_expected.not_to contain_class('git') }
it { is_expected.to contain_package('rubygem-r10k') }
end
context 'with zypper provider' do
let :params do
{
install_options: '',
keywords: '',
manage_ruby_dependency: 'declare',
package_name: 'r10k',
provider: 'zypper',
version: 'latest',
puppet_master: true
}
end
let :facts do
{
osfamily: 'Suse',
operatingsystemrelease: '11.3'
}
end
it { is_expected.not_to contain_class('git') }
it { is_expected.to contain_package('r10k') }
end
context 'with portage provider' do
let :params do
{
install_options: '',
keywords: ['~amd64', '~x86'],
manage_ruby_dependency: 'declare',
package_name: 'app-admin/r10k',
provider: 'portage',
version: version,
puppet_master: true
}
end
let :facts do
{
osfamily: 'Gentoo',
operatingsystemrelease: '2.1'
}
end
it { is_expected.not_to contain_class('git') }
it do
is_expected.to contain_class('r10k::install::portage').with(
package_name: 'app-admin/r10k',
keywords: ['~amd64', '~x86'],
version: version
)
end
it do
is_expected.to contain_package_keywords('dev-ruby/cri').with(
keywords: ['~amd64', '~x86'],
target: 'puppet'
)
end
it do
is_expected.to contain_portage__package('app-admin/r10k').with(
keywords: ['~amd64', '~x86'],
ensure: version,
target: 'puppet'
)
end
it { is_expected.to contain_package('app-admin/r10k') }
it { is_expected.not_to contain_package('r10k') }
end
end
end
end