rspec-puppet-facts 3.0.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/.rubocop_todo.yml +62 -5
- data/CHANGELOG.md +66 -12
- data/Gemfile +4 -4
- data/README.md +56 -29
- data/Rakefile +19 -7
- data/lib/rspec-puppet-facts/version.rb +1 -1
- data/lib/rspec-puppet-facts.rb +42 -58
- data/rspec-puppet-facts.gemspec +2 -2
- data/spec/fixtures/metadata.json +4 -5
- data/spec/rspec_puppet_facts_spec.rb +209 -322
- metadata +9 -15
|
@@ -8,7 +8,9 @@ describe RspecPuppetFacts do
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
describe '.stringify_keys' do
|
|
11
|
-
it {
|
|
11
|
+
it {
|
|
12
|
+
expect(described_class.stringify_keys({ os: { family: 'RedHat' } })).to eq({ 'os' => { 'family' => 'RedHat' } })
|
|
13
|
+
}
|
|
12
14
|
end
|
|
13
15
|
|
|
14
16
|
describe '.facter_version_for_puppet_version' do
|
|
@@ -137,10 +139,10 @@ describe RspecPuppetFacts do
|
|
|
137
139
|
subject(:result) do
|
|
138
140
|
on_supported_os(
|
|
139
141
|
{
|
|
140
|
-
:
|
|
142
|
+
supported_os: [
|
|
141
143
|
{
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
'operatingsystem' => 'Debian',
|
|
145
|
+
'operatingsystemrelease' => ['12'],
|
|
144
146
|
},
|
|
145
147
|
],
|
|
146
148
|
},
|
|
@@ -148,7 +150,7 @@ describe RspecPuppetFacts do
|
|
|
148
150
|
end
|
|
149
151
|
|
|
150
152
|
let(:get_keys) do
|
|
151
|
-
proc { |r| r.keys + r.select { |_,v| v.is_a?(Hash) }.map { |_,v| get_keys.call(v) }.flatten }
|
|
153
|
+
proc { |r| r.keys + r.select { |_, v| v.is_a?(Hash) }.map { |_, v| get_keys.call(v) }.flatten }
|
|
152
154
|
end
|
|
153
155
|
|
|
154
156
|
context 'set to true' do
|
|
@@ -161,7 +163,7 @@ describe RspecPuppetFacts do
|
|
|
161
163
|
end
|
|
162
164
|
|
|
163
165
|
it 'returns a fact set with all the keys as Strings' do
|
|
164
|
-
expect(get_keys.call(result['debian-
|
|
166
|
+
expect(get_keys.call(result['debian-12-x86_64'])).to all(be_a(String))
|
|
165
167
|
end
|
|
166
168
|
end
|
|
167
169
|
|
|
@@ -171,7 +173,7 @@ describe RspecPuppetFacts do
|
|
|
171
173
|
end
|
|
172
174
|
|
|
173
175
|
it 'returns a fact set with all the keys as Symbols or Strings' do
|
|
174
|
-
expect(get_keys.call(result['debian-
|
|
176
|
+
expect(get_keys.call(result['debian-12-x86_64'])).to all(be_a(Symbol).or(be_a(String)))
|
|
175
177
|
end
|
|
176
178
|
end
|
|
177
179
|
end
|
|
@@ -209,26 +211,20 @@ describe RspecPuppetFacts do
|
|
|
209
211
|
is_expected.to be_a Hash
|
|
210
212
|
end
|
|
211
213
|
|
|
212
|
-
it 'has 5 elements' do
|
|
213
|
-
expect(subject.size).to eq 5
|
|
214
|
-
end
|
|
215
|
-
|
|
216
214
|
it 'returns supported OS' do
|
|
217
|
-
expect(subject.keys
|
|
218
|
-
debian-
|
|
219
|
-
debian-
|
|
220
|
-
redhat-
|
|
221
|
-
redhat-
|
|
222
|
-
redhat-7-x86_64
|
|
215
|
+
expect(subject.keys).to contain_exactly(
|
|
216
|
+
'debian-11-x86_64',
|
|
217
|
+
'debian-12-x86_64',
|
|
218
|
+
'redhat-8-x86_64',
|
|
219
|
+
'redhat-9-x86_64',
|
|
223
220
|
)
|
|
224
221
|
end
|
|
225
222
|
|
|
226
223
|
it 'is able to filter the received OS facts' do
|
|
227
224
|
allow(described_class).to receive(:spec_facts_os_filter).and_return('redhat')
|
|
228
|
-
expect(subject.keys
|
|
229
|
-
redhat-
|
|
230
|
-
redhat-
|
|
231
|
-
redhat-7-x86_64
|
|
225
|
+
expect(subject.keys).to contain_exactly(
|
|
226
|
+
'redhat-8-x86_64',
|
|
227
|
+
'redhat-9-x86_64',
|
|
232
228
|
)
|
|
233
229
|
end
|
|
234
230
|
end
|
|
@@ -249,63 +245,58 @@ describe RspecPuppetFacts do
|
|
|
249
245
|
context 'With a wrong operatingsystem_support section' do
|
|
250
246
|
let(:metadata) do
|
|
251
247
|
{
|
|
252
|
-
|
|
248
|
+
'operatingsystem_support' => 'Ubuntu',
|
|
253
249
|
}
|
|
254
250
|
end
|
|
255
251
|
|
|
256
252
|
it { expect { subject }.to raise_error(StandardError, /Unknown operatingsystem support/) }
|
|
257
253
|
end
|
|
258
254
|
end
|
|
259
|
-
|
|
260
255
|
end
|
|
261
256
|
end
|
|
262
257
|
|
|
263
258
|
context 'When specifying supported_os' do
|
|
264
|
-
subject
|
|
259
|
+
subject do
|
|
265
260
|
on_supported_os(
|
|
266
261
|
{
|
|
267
|
-
:
|
|
262
|
+
supported_os: [
|
|
268
263
|
{
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
264
|
+
'operatingsystem' => 'Debian',
|
|
265
|
+
'operatingsystemrelease' => %w[
|
|
266
|
+
11
|
|
267
|
+
12
|
|
273
268
|
],
|
|
274
269
|
},
|
|
275
270
|
{
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
271
|
+
'operatingsystem' => 'RedHat',
|
|
272
|
+
'operatingsystemrelease' => %w[
|
|
273
|
+
8
|
|
274
|
+
9
|
|
280
275
|
],
|
|
281
276
|
},
|
|
282
277
|
],
|
|
283
278
|
},
|
|
284
279
|
)
|
|
285
|
-
|
|
280
|
+
end
|
|
286
281
|
|
|
287
282
|
it 'returns a hash' do
|
|
288
283
|
is_expected.to be_a Hash
|
|
289
284
|
end
|
|
290
285
|
|
|
291
|
-
it 'has 4 elements' do
|
|
292
|
-
expect(subject.size).to eq 4
|
|
293
|
-
end
|
|
294
|
-
|
|
295
286
|
it 'returns supported OS' do
|
|
296
|
-
expect(subject.keys
|
|
297
|
-
debian-
|
|
298
|
-
debian-
|
|
299
|
-
redhat-
|
|
300
|
-
redhat-
|
|
287
|
+
expect(subject.keys).to contain_exactly(
|
|
288
|
+
'debian-11-x86_64',
|
|
289
|
+
'debian-12-x86_64',
|
|
290
|
+
'redhat-8-x86_64',
|
|
291
|
+
'redhat-9-x86_64',
|
|
301
292
|
)
|
|
302
293
|
end
|
|
303
294
|
|
|
304
295
|
it 'is able to filter the received OS facts' do
|
|
305
296
|
allow(described_class).to receive(:spec_facts_os_filter).and_return('redhat')
|
|
306
|
-
expect(subject.keys
|
|
307
|
-
redhat-
|
|
308
|
-
redhat-
|
|
297
|
+
expect(subject.keys).to contain_exactly(
|
|
298
|
+
'redhat-8-x86_64',
|
|
299
|
+
'redhat-9-x86_64',
|
|
309
300
|
)
|
|
310
301
|
end
|
|
311
302
|
end
|
|
@@ -314,8 +305,8 @@ describe RspecPuppetFacts do
|
|
|
314
305
|
subject(:factsets) do
|
|
315
306
|
on_supported_os(
|
|
316
307
|
{
|
|
317
|
-
:
|
|
318
|
-
{ 'operatingsystem' => 'RedHat', 'operatingsystemrelease' => '
|
|
308
|
+
supported_os: [
|
|
309
|
+
{ 'operatingsystem' => 'RedHat', 'operatingsystemrelease' => '9' },
|
|
319
310
|
],
|
|
320
311
|
},
|
|
321
312
|
)
|
|
@@ -325,287 +316,245 @@ describe RspecPuppetFacts do
|
|
|
325
316
|
expect(factsets).to be_a(Hash)
|
|
326
317
|
end
|
|
327
318
|
|
|
328
|
-
it 'returns a single fact set' do
|
|
329
|
-
expect(factsets.size).to eq(1)
|
|
330
|
-
end
|
|
331
|
-
|
|
332
319
|
it 'returns a fact set for the specified release' do
|
|
333
|
-
expect(factsets).to
|
|
320
|
+
expect(factsets).to a_hash_including('redhat-9-x86_64' => hash_including({ os: hash_including({ 'release' => hash_including({ 'major' => '9' }) }) }))
|
|
334
321
|
end
|
|
335
322
|
end
|
|
336
323
|
|
|
337
324
|
context 'When testing Ubuntu' do
|
|
338
|
-
subject
|
|
325
|
+
subject do
|
|
339
326
|
on_supported_os(
|
|
340
327
|
{
|
|
341
|
-
:
|
|
328
|
+
supported_os: [
|
|
342
329
|
{
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
330
|
+
'operatingsystem' => 'Ubuntu',
|
|
331
|
+
'operatingsystemrelease' => [
|
|
332
|
+
'18.04',
|
|
333
|
+
'20.04',
|
|
334
|
+
'22.04',
|
|
348
335
|
],
|
|
349
336
|
},
|
|
350
337
|
],
|
|
351
338
|
},
|
|
352
339
|
)
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
let(:expected_fact_sets) do
|
|
356
|
-
['ubuntu-12.04-x86_64', 'ubuntu-14.04-x86_64', 'ubuntu-16.04-x86_64']
|
|
357
340
|
end
|
|
358
341
|
|
|
359
342
|
it 'returns a hash' do
|
|
360
|
-
expect(subject
|
|
361
|
-
end
|
|
362
|
-
|
|
363
|
-
it 'has 3 elements' do
|
|
364
|
-
expect(subject.size).to eq(expected_fact_sets.size)
|
|
343
|
+
expect(subject).to be_a Hash
|
|
365
344
|
end
|
|
366
345
|
|
|
367
346
|
it 'returns supported OS' do
|
|
368
|
-
expect(subject.keys
|
|
347
|
+
expect(subject.keys).to contain_exactly(
|
|
348
|
+
'ubuntu-18.04-x86_64',
|
|
349
|
+
'ubuntu-20.04-x86_64',
|
|
350
|
+
'ubuntu-22.04-x86_64',
|
|
351
|
+
)
|
|
369
352
|
end
|
|
370
353
|
end
|
|
371
354
|
|
|
372
355
|
context 'When testing FreeBSD 10' do
|
|
373
|
-
subject
|
|
356
|
+
subject do
|
|
374
357
|
on_supported_os(
|
|
375
358
|
{
|
|
376
|
-
:
|
|
359
|
+
supported_os: [
|
|
377
360
|
{
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
361
|
+
'operatingsystem' => 'FreeBSD',
|
|
362
|
+
'operatingsystemrelease' => [
|
|
363
|
+
'13',
|
|
381
364
|
],
|
|
382
365
|
},
|
|
383
366
|
],
|
|
384
|
-
:
|
|
367
|
+
facterversion: '4.5',
|
|
385
368
|
},
|
|
386
369
|
)
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
it 'returns a hash' do
|
|
390
|
-
expect(subject.class).to eq Hash
|
|
391
370
|
end
|
|
392
371
|
|
|
393
|
-
it '
|
|
394
|
-
expect(subject
|
|
372
|
+
it 'returns a hash' do
|
|
373
|
+
expect(subject).to be_a Hash
|
|
395
374
|
end
|
|
396
375
|
|
|
397
376
|
it 'returns supported OS' do
|
|
398
|
-
expect(subject.keys
|
|
399
|
-
'freebsd-
|
|
400
|
-
|
|
377
|
+
expect(subject.keys).to contain_exactly(
|
|
378
|
+
'freebsd-13-amd64',
|
|
379
|
+
)
|
|
401
380
|
end
|
|
402
381
|
end
|
|
403
382
|
|
|
404
383
|
context 'When testing OpenBSD' do
|
|
405
|
-
subject
|
|
384
|
+
subject do
|
|
406
385
|
on_supported_os(
|
|
407
386
|
{
|
|
408
|
-
:
|
|
387
|
+
supported_os: [
|
|
409
388
|
{
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
389
|
+
'operatingsystem' => 'OpenBSD',
|
|
390
|
+
'operatingsystemrelease' => [
|
|
391
|
+
'7.5',
|
|
413
392
|
],
|
|
414
393
|
},
|
|
415
394
|
],
|
|
416
|
-
:
|
|
395
|
+
facterversion: '4.7',
|
|
417
396
|
},
|
|
418
397
|
)
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
it 'returns a hash' do
|
|
422
|
-
expect(subject.class).to eq Hash
|
|
423
398
|
end
|
|
424
399
|
|
|
425
|
-
it '
|
|
426
|
-
expect(subject
|
|
400
|
+
it 'returns a hash' do
|
|
401
|
+
expect(subject).to be_a Hash
|
|
427
402
|
end
|
|
428
403
|
|
|
429
404
|
it 'returns supported OS' do
|
|
430
|
-
expect(subject.keys
|
|
431
|
-
'openbsd-
|
|
432
|
-
|
|
405
|
+
expect(subject.keys).to contain_exactly(
|
|
406
|
+
'openbsd-7-amd64',
|
|
407
|
+
)
|
|
433
408
|
end
|
|
434
409
|
end
|
|
435
410
|
|
|
436
|
-
context 'When testing Solaris 11'
|
|
437
|
-
subject
|
|
411
|
+
context 'When testing Solaris 11' do
|
|
412
|
+
subject do
|
|
438
413
|
on_supported_os(
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
],
|
|
446
|
-
},
|
|
414
|
+
{
|
|
415
|
+
supported_os: [
|
|
416
|
+
{
|
|
417
|
+
'operatingsystem' => 'Solaris',
|
|
418
|
+
'operatingsystemrelease' => [
|
|
419
|
+
'11',
|
|
447
420
|
],
|
|
448
|
-
|
|
421
|
+
},
|
|
422
|
+
],
|
|
423
|
+
facterversion: '4.0',
|
|
424
|
+
},
|
|
449
425
|
)
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
it 'returns a hash' do
|
|
453
|
-
expect(subject.class).to eq Hash
|
|
454
426
|
end
|
|
455
427
|
|
|
456
|
-
it '
|
|
457
|
-
expect(subject
|
|
428
|
+
it 'returns a hash' do
|
|
429
|
+
expect(subject).to be_a Hash
|
|
458
430
|
end
|
|
459
431
|
|
|
460
432
|
it 'returns supported OS' do
|
|
461
|
-
|
|
462
|
-
|
|
433
|
+
pending('2024-06-07: we dont have a suitable solaris 11 factset in facterdb')
|
|
434
|
+
expect(subject.keys).to contain_exactly(
|
|
435
|
+
'solaris-11-i86pc',
|
|
463
436
|
)
|
|
464
437
|
end
|
|
465
438
|
end
|
|
466
439
|
|
|
467
440
|
context 'When testing AIX 7.1' do
|
|
468
|
-
subject
|
|
441
|
+
subject do
|
|
469
442
|
on_supported_os(
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
],
|
|
477
|
-
},
|
|
443
|
+
{
|
|
444
|
+
supported_os: [
|
|
445
|
+
{
|
|
446
|
+
'operatingsystem' => 'AIX',
|
|
447
|
+
'operatingsystemrelease' => [
|
|
448
|
+
'7.1', '7100',
|
|
478
449
|
],
|
|
479
|
-
|
|
480
|
-
|
|
450
|
+
},
|
|
451
|
+
],
|
|
452
|
+
facterversion: '3.9',
|
|
453
|
+
},
|
|
481
454
|
)
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
it 'returns a hash' do
|
|
485
|
-
expect(subject.class).to eq Hash
|
|
486
455
|
end
|
|
487
456
|
|
|
488
|
-
it '
|
|
489
|
-
expect(subject
|
|
457
|
+
it 'returns a hash' do
|
|
458
|
+
expect(subject).to be_a Hash
|
|
490
459
|
end
|
|
491
460
|
|
|
492
461
|
it 'returns supported OS' do
|
|
493
462
|
# NOTE: See FACT-1827 for details on the IBM,8284-22A part
|
|
494
463
|
# That has to match whatever hardware generated the facts file.
|
|
495
|
-
|
|
496
|
-
|
|
464
|
+
pending('2024-06-07: we dont have a suitable solaris 11 factset in facterdb')
|
|
465
|
+
expect(subject.keys).to contain_exactly(
|
|
466
|
+
'aix-7100-IBM,8284-22A',
|
|
497
467
|
)
|
|
498
468
|
end
|
|
499
469
|
end
|
|
500
470
|
|
|
501
|
-
context 'When testing Windows'
|
|
471
|
+
context 'When testing Windows' do
|
|
502
472
|
subject do
|
|
503
473
|
on_supported_os(
|
|
504
474
|
{
|
|
505
|
-
:
|
|
475
|
+
supported_os: [
|
|
506
476
|
{
|
|
507
|
-
'operatingsystem'
|
|
477
|
+
'operatingsystem' => 'Windows',
|
|
508
478
|
'operatingsystemrelease' => release,
|
|
509
479
|
},
|
|
510
480
|
],
|
|
511
|
-
:
|
|
481
|
+
facterversion: facterversion,
|
|
512
482
|
},
|
|
513
483
|
)
|
|
514
484
|
end
|
|
515
485
|
|
|
516
|
-
let(:facterversion) { '
|
|
486
|
+
let(:facterversion) { '4.2' }
|
|
517
487
|
|
|
518
488
|
context 'with a standard release' do
|
|
519
|
-
let(:release) { ['
|
|
489
|
+
let(:release) { ['10'] }
|
|
520
490
|
|
|
521
491
|
it { is_expected.to be_a(Hash) }
|
|
522
|
-
it { is_expected.to
|
|
523
|
-
it { is_expected.to include('windows-7-x86_64' => an_instance_of(Hash)) }
|
|
492
|
+
it { is_expected.to match('windows-10-x86_64' => an_instance_of(Hash)) }
|
|
524
493
|
end
|
|
525
494
|
|
|
526
495
|
context 'with a revision release' do
|
|
527
496
|
let(:release) { ['2012 R2'] }
|
|
528
497
|
|
|
529
498
|
it { is_expected.to be_a(Hash) }
|
|
530
|
-
it { is_expected.to
|
|
531
|
-
it { is_expected.to include('windows-2012 R2-x86_64' => an_instance_of(Hash)) }
|
|
499
|
+
it { is_expected.to match('windows-2012 R2-x86_64' => an_instance_of(Hash)) }
|
|
532
500
|
end
|
|
533
501
|
|
|
534
502
|
context 'with a Server prefixed release' do
|
|
535
503
|
let(:release) { ['Server 2012'] }
|
|
536
504
|
|
|
537
505
|
it { is_expected.to be_a(Hash) }
|
|
538
|
-
it { is_expected.to
|
|
539
|
-
it { is_expected.to include('windows-2012-x86_64' => an_instance_of(Hash)) }
|
|
506
|
+
it { is_expected.to match('windows-2012-x86_64' => an_instance_of(Hash)) }
|
|
540
507
|
end
|
|
541
508
|
|
|
542
509
|
context 'with a 2016 release' do
|
|
543
510
|
let(:release) { ['2016'] }
|
|
544
511
|
|
|
545
512
|
it { is_expected.to be_a(Hash) }
|
|
546
|
-
it { is_expected.to
|
|
547
|
-
it { is_expected.to include('windows-2016-x86_64' => an_instance_of(Hash)) }
|
|
548
|
-
end
|
|
549
|
-
|
|
550
|
-
context 'with a 2016 release and Facter < 3.4' do
|
|
551
|
-
let(:release) { ['2016'] }
|
|
552
|
-
let(:facterversion) { '3.3.0' }
|
|
553
|
-
|
|
554
|
-
it { is_expected.to be_a(Hash) }
|
|
555
|
-
it { is_expected.to have_attributes(:size => 1) }
|
|
556
|
-
|
|
557
|
-
it 'munges the operatingsystemmajrelease to 2016' do
|
|
558
|
-
is_expected.to include('windows-2016-x86_64' => an_instance_of(Hash))
|
|
559
|
-
end
|
|
513
|
+
it { is_expected.to match('windows-2016-x86_64' => an_instance_of(Hash)) }
|
|
560
514
|
end
|
|
561
515
|
end
|
|
562
516
|
|
|
563
517
|
context 'When operatingsystemrelease has space' do
|
|
564
|
-
subject
|
|
518
|
+
subject do
|
|
565
519
|
on_supported_os(
|
|
566
520
|
{
|
|
567
|
-
:
|
|
521
|
+
supported_os: [
|
|
568
522
|
{
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
523
|
+
'operatingsystem' => 'SLES',
|
|
524
|
+
'operatingsystemrelease' => [
|
|
525
|
+
'11 SP1',
|
|
572
526
|
],
|
|
573
527
|
},
|
|
574
528
|
],
|
|
575
529
|
},
|
|
576
530
|
)
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
it 'returns a hash' do
|
|
580
|
-
expect(subject.class).to eq Hash
|
|
581
531
|
end
|
|
582
532
|
|
|
583
|
-
it '
|
|
584
|
-
expect(subject
|
|
533
|
+
it 'returns a hash' do
|
|
534
|
+
expect(subject).to be_a Hash
|
|
585
535
|
end
|
|
586
536
|
|
|
587
537
|
it 'returns supported OS' do
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
]
|
|
538
|
+
pending('2024-06-7: facterdb has no factset with space in the system release')
|
|
539
|
+
expect(subject.keys).to contain_exactly('sles-11-x86_64')
|
|
591
540
|
end
|
|
592
541
|
end
|
|
593
542
|
|
|
594
543
|
context 'When specifying wrong supported_os' do
|
|
595
|
-
subject
|
|
544
|
+
subject do
|
|
596
545
|
on_supported_os(
|
|
597
546
|
{
|
|
598
|
-
:
|
|
547
|
+
supported_os: [
|
|
599
548
|
{
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
549
|
+
'operatingsystem' => 'Debian',
|
|
550
|
+
'operatingsystemrelease' => [
|
|
551
|
+
'4',
|
|
603
552
|
],
|
|
604
553
|
},
|
|
605
554
|
],
|
|
606
555
|
},
|
|
607
556
|
)
|
|
608
|
-
|
|
557
|
+
end
|
|
609
558
|
|
|
610
559
|
it 'outputs warning message' do
|
|
611
560
|
expect(described_class).to receive(:warning).with(/No facts were found in the FacterDB/)
|
|
@@ -614,35 +563,31 @@ describe RspecPuppetFacts do
|
|
|
614
563
|
end
|
|
615
564
|
|
|
616
565
|
context 'When specifying rolling release operating system' do
|
|
617
|
-
subject
|
|
566
|
+
subject do
|
|
618
567
|
on_supported_os(
|
|
619
568
|
{
|
|
620
|
-
:
|
|
569
|
+
supported_os: [
|
|
621
570
|
{
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
571
|
+
'operatingsystem' => 'Debian',
|
|
572
|
+
'operatingsystemrelease' => [
|
|
573
|
+
'12',
|
|
625
574
|
],
|
|
626
575
|
},
|
|
627
576
|
{
|
|
628
|
-
|
|
577
|
+
'operatingsystem' => 'Gentoo',
|
|
629
578
|
},
|
|
630
579
|
],
|
|
631
|
-
:
|
|
580
|
+
facterversion: '4.6',
|
|
632
581
|
},
|
|
633
582
|
)
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
it 'returns a hash' do
|
|
637
|
-
expect(subject.class).to eq Hash
|
|
638
583
|
end
|
|
639
584
|
|
|
640
|
-
it '
|
|
641
|
-
expect(subject
|
|
585
|
+
it 'returns a hash' do
|
|
586
|
+
expect(subject).to be_a Hash
|
|
642
587
|
end
|
|
643
588
|
|
|
644
589
|
it 'returns supported OS' do
|
|
645
|
-
expect(subject.keys
|
|
590
|
+
expect(subject.keys).to contain_exactly(a_string_matching(/gentoo-\d+-x86_64/), 'debian-12-x86_64')
|
|
646
591
|
end
|
|
647
592
|
end
|
|
648
593
|
|
|
@@ -650,9 +595,9 @@ describe RspecPuppetFacts do
|
|
|
650
595
|
subject do
|
|
651
596
|
on_supported_os(
|
|
652
597
|
{
|
|
653
|
-
:
|
|
598
|
+
supported_os: [
|
|
654
599
|
{
|
|
655
|
-
'operatingsystem'
|
|
600
|
+
'operatingsystem' => 'IOS',
|
|
656
601
|
'operatingsystemrelease' => ['12.2(25)EWA9'],
|
|
657
602
|
},
|
|
658
603
|
],
|
|
@@ -666,12 +611,12 @@ describe RspecPuppetFacts do
|
|
|
666
611
|
|
|
667
612
|
it 'escapes the parens in the filter' do
|
|
668
613
|
filter = {
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
614
|
+
'os.name' => 'IOS',
|
|
615
|
+
'os.release.full' => '/^12\\.2\\(25\\)EWA9/',
|
|
616
|
+
'os.hardware' => 'x86_64',
|
|
672
617
|
}
|
|
673
618
|
|
|
674
|
-
expect(FacterDB).to receive(:get_facts).with(filter).once
|
|
619
|
+
expect(FacterDB).to receive(:get_facts).with(filter, symbolize_keys: true).once
|
|
675
620
|
subject
|
|
676
621
|
end
|
|
677
622
|
|
|
@@ -684,24 +629,23 @@ describe RspecPuppetFacts do
|
|
|
684
629
|
subject do
|
|
685
630
|
on_supported_os(
|
|
686
631
|
supported_os: [
|
|
687
|
-
{ 'operatingsystem' => 'CentOS', 'operatingsystemrelease' => %w[
|
|
632
|
+
{ 'operatingsystem' => 'CentOS', 'operatingsystemrelease' => %w[9] },
|
|
688
633
|
],
|
|
689
634
|
)
|
|
690
635
|
end
|
|
691
636
|
|
|
692
637
|
before do
|
|
693
|
-
RSpec.configuration.default_facter_version = '
|
|
638
|
+
RSpec.configuration.default_facter_version = '4.6.1'
|
|
694
639
|
end
|
|
695
640
|
|
|
696
641
|
after do
|
|
697
642
|
RSpec.configuration.default_facter_version = Facter.version
|
|
698
643
|
end
|
|
699
644
|
|
|
700
|
-
|
|
701
645
|
it 'returns facts from the specified default Facter version' do
|
|
702
646
|
is_expected.to match(
|
|
703
|
-
'centos-
|
|
704
|
-
:
|
|
647
|
+
'centos-9-x86_64' => include(
|
|
648
|
+
facterversion: /\A4\.6\./,
|
|
705
649
|
),
|
|
706
650
|
)
|
|
707
651
|
end
|
|
@@ -711,21 +655,20 @@ describe RspecPuppetFacts do
|
|
|
711
655
|
subject do
|
|
712
656
|
on_supported_os(
|
|
713
657
|
supported_os: [
|
|
714
|
-
{ 'operatingsystem' => 'CentOS', 'operatingsystemrelease' => %w[
|
|
658
|
+
{ 'operatingsystem' => 'CentOS', 'operatingsystemrelease' => %w[9] },
|
|
715
659
|
],
|
|
716
|
-
facterversion:
|
|
660
|
+
facterversion: '4.7.99',
|
|
717
661
|
)
|
|
718
662
|
end
|
|
719
663
|
|
|
720
664
|
before do
|
|
721
|
-
allow(Facter).to receive(:version).and_return('
|
|
665
|
+
allow(Facter).to receive(:version).and_return('4.6')
|
|
722
666
|
end
|
|
723
667
|
|
|
724
|
-
|
|
725
668
|
it 'returns facts from a facter version matching version and below' do
|
|
726
669
|
is_expected.to match(
|
|
727
|
-
'centos-
|
|
728
|
-
:
|
|
670
|
+
'centos-9-x86_64' => include(
|
|
671
|
+
facterversion: /\A4\.[0-7]\./,
|
|
729
672
|
),
|
|
730
673
|
)
|
|
731
674
|
end
|
|
@@ -741,88 +684,33 @@ describe RspecPuppetFacts do
|
|
|
741
684
|
end
|
|
742
685
|
end
|
|
743
686
|
|
|
744
|
-
context 'With a custom facterversion (
|
|
745
|
-
subject do
|
|
746
|
-
on_supported_os(
|
|
747
|
-
supported_os: [
|
|
748
|
-
{ 'operatingsystem' => 'CentOS', 'operatingsystemrelease' => %w[7] },
|
|
749
|
-
],
|
|
750
|
-
facterversion: '3.1',
|
|
751
|
-
)
|
|
752
|
-
end
|
|
753
|
-
|
|
754
|
-
it 'returns facts from a facter version matching 3.1' do
|
|
755
|
-
is_expected.to match(
|
|
756
|
-
'centos-7-x86_64' => include(:facterversion => '3.1.6'),
|
|
757
|
-
)
|
|
758
|
-
end
|
|
759
|
-
end
|
|
760
|
-
|
|
761
|
-
context 'With a custom facterversion (3.1.2) in the options hash' do
|
|
762
|
-
subject do
|
|
763
|
-
on_supported_os(
|
|
764
|
-
supported_os: [
|
|
765
|
-
{ 'operatingsystem' => 'CentOS', 'operatingsystemrelease' => %w[7] },
|
|
766
|
-
],
|
|
767
|
-
facterversion: '3.1.2',
|
|
768
|
-
)
|
|
769
|
-
end
|
|
770
|
-
|
|
771
|
-
it 'returns facts from a facter version matching 3.1' do
|
|
772
|
-
is_expected.to match(
|
|
773
|
-
'centos-7-x86_64' => include(:facterversion => '3.1.6'),
|
|
774
|
-
)
|
|
775
|
-
end
|
|
776
|
-
end
|
|
777
|
-
|
|
778
|
-
context 'With a custom facterversion (3.3) in the options hash' do
|
|
687
|
+
context 'With a custom facterversion (4.6) in the options hash' do
|
|
779
688
|
subject do
|
|
780
689
|
on_supported_os(
|
|
781
690
|
supported_os: [
|
|
782
|
-
{ 'operatingsystem' => 'CentOS', 'operatingsystemrelease' => %w[
|
|
691
|
+
{ 'operatingsystem' => 'CentOS', 'operatingsystemrelease' => %w[9] },
|
|
783
692
|
],
|
|
784
|
-
facterversion: '
|
|
693
|
+
facterversion: '4.6',
|
|
785
694
|
)
|
|
786
695
|
end
|
|
787
696
|
|
|
788
|
-
it 'returns facts from a facter version matching
|
|
789
|
-
is_expected.to match(
|
|
790
|
-
'centos-7-x86_64' => include(:facterversion => '3.3.0'),
|
|
791
|
-
)
|
|
697
|
+
it 'returns facts from a facter version matching 4.6' do
|
|
698
|
+
is_expected.to match('centos-9-x86_64' => include(facterversion: '4.6.1'))
|
|
792
699
|
end
|
|
793
700
|
end
|
|
794
701
|
|
|
795
|
-
context 'With a custom facterversion (
|
|
702
|
+
context 'With a custom facterversion (4.6.1) in the options hash' do
|
|
796
703
|
subject do
|
|
797
704
|
on_supported_os(
|
|
798
705
|
supported_os: [
|
|
799
|
-
{ 'operatingsystem' => 'CentOS', 'operatingsystemrelease' => %w[
|
|
706
|
+
{ 'operatingsystem' => 'CentOS', 'operatingsystemrelease' => %w[9] },
|
|
800
707
|
],
|
|
801
|
-
facterversion: '
|
|
708
|
+
facterversion: '4.6.1',
|
|
802
709
|
)
|
|
803
710
|
end
|
|
804
711
|
|
|
805
|
-
it 'returns facts from a facter version matching
|
|
806
|
-
is_expected.to match(
|
|
807
|
-
'centos-7-x86_64' => include(:facterversion => '3.3.0'),
|
|
808
|
-
)
|
|
809
|
-
end
|
|
810
|
-
end
|
|
811
|
-
|
|
812
|
-
context 'When querying a fact set that does not have an operatingsystemmajrelease fact' do
|
|
813
|
-
subject do
|
|
814
|
-
on_supported_os(
|
|
815
|
-
supported_os: [
|
|
816
|
-
{ 'operatingsystem' => 'SLES', 'operatingsystemrelease' => ['11'] },
|
|
817
|
-
],
|
|
818
|
-
facterversion: '2.1.0',
|
|
819
|
-
)
|
|
820
|
-
end
|
|
821
|
-
|
|
822
|
-
it 'splits the operatingsystemrelease fact value to get the major release' do
|
|
823
|
-
is_expected.to match(
|
|
824
|
-
'sles-11-x86_64' => include(:operatingsystemrelease => '11.3'),
|
|
825
|
-
)
|
|
712
|
+
it 'returns facts from a facter version matching 4.6.1' do
|
|
713
|
+
is_expected.to match('centos-9-x86_64' => include(facterversion: '4.6.1'))
|
|
826
714
|
end
|
|
827
715
|
end
|
|
828
716
|
|
|
@@ -846,52 +734,48 @@ describe RspecPuppetFacts do
|
|
|
846
734
|
subject do
|
|
847
735
|
on_supported_os(
|
|
848
736
|
supported_os: [
|
|
849
|
-
{ 'operatingsystem' => 'CentOS', 'operatingsystemrelease' => %w[
|
|
850
|
-
{ 'operatingsystem' => '
|
|
737
|
+
{ 'operatingsystem' => 'CentOS', 'operatingsystemrelease' => %w[9] },
|
|
738
|
+
{ 'operatingsystem' => 'Debian', 'operatingsystemrelease' => %w[12] },
|
|
851
739
|
],
|
|
852
|
-
facterversion: '
|
|
740
|
+
facterversion: '4.6.1',
|
|
853
741
|
)
|
|
854
742
|
end
|
|
855
743
|
|
|
856
744
|
before do
|
|
857
745
|
allow(FacterDB).to receive(:get_facts).and_call_original
|
|
858
746
|
allow(FacterDB).to receive(:get_facts).with(
|
|
859
|
-
{
|
|
747
|
+
{ 'os.name' => 'CentOS', 'os.release.full' => '/^9/', 'os.hardware' => 'x86_64' }, symbolize_keys: true
|
|
860
748
|
).and_wrap_original do |m, *args|
|
|
861
|
-
m.call(*args).reject { |facts| facts[:facterversion].start_with?('
|
|
749
|
+
m.call(*args).reject { |facts| facts[:facterversion].start_with?('4.6.') }
|
|
862
750
|
end
|
|
863
751
|
end
|
|
864
752
|
|
|
865
|
-
it 'returns CentOS facts from a facter version matching
|
|
866
|
-
is_expected.to include(
|
|
867
|
-
'centos-7-x86_64' => include(:facterversion => '3.8.0'),
|
|
868
|
-
)
|
|
753
|
+
it 'returns CentOS facts from a facter version matching 4.5' do
|
|
754
|
+
is_expected.to include('centos-9-x86_64' => include(facterversion: '4.5.2'))
|
|
869
755
|
end
|
|
870
756
|
|
|
871
|
-
it 'returns
|
|
872
|
-
is_expected.to include(
|
|
873
|
-
'opensuse-42-x86_64' => include(:facterversion => '3.9.2'),
|
|
874
|
-
)
|
|
757
|
+
it 'returns Debian facts from a facter version matching 4.6.1' do
|
|
758
|
+
is_expected.to include('debian-12-x86_64' => include(facterversion: '4.6.1'))
|
|
875
759
|
end
|
|
876
760
|
end
|
|
877
761
|
end
|
|
878
762
|
|
|
879
763
|
describe '#add_custom_fact' do
|
|
880
|
-
subject
|
|
764
|
+
subject do
|
|
881
765
|
on_supported_os(
|
|
882
766
|
{
|
|
883
|
-
:
|
|
767
|
+
supported_os: [
|
|
884
768
|
{
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
769
|
+
'operatingsystem' => 'RedHat',
|
|
770
|
+
'operatingsystemrelease' => %w[
|
|
771
|
+
8
|
|
772
|
+
9
|
|
889
773
|
],
|
|
890
774
|
},
|
|
891
775
|
],
|
|
892
776
|
},
|
|
893
777
|
)
|
|
894
|
-
|
|
778
|
+
end
|
|
895
779
|
|
|
896
780
|
before do
|
|
897
781
|
described_class.reset
|
|
@@ -899,49 +783,51 @@ describe RspecPuppetFacts do
|
|
|
899
783
|
|
|
900
784
|
it 'adds a simple fact and value' do
|
|
901
785
|
add_custom_fact 'root_home', '/root'
|
|
902
|
-
expect(subject['redhat-
|
|
786
|
+
expect(subject['redhat-9-x86_64'][:root_home]).to eq '/root'
|
|
903
787
|
end
|
|
904
788
|
|
|
905
789
|
it 'merges a fact value into fact when merge_facts passed' do
|
|
906
790
|
add_custom_fact :identity, { 'user' => 'test_user' }, merge_facts: true
|
|
907
|
-
expect(subject['redhat-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
791
|
+
expect(subject['redhat-9-x86_64'][:identity]).to eq(
|
|
792
|
+
{
|
|
793
|
+
'gid' => 0,
|
|
794
|
+
'group' => 'root',
|
|
795
|
+
'privileged' => true,
|
|
796
|
+
'uid' => 0,
|
|
797
|
+
'user' => 'test_user',
|
|
798
|
+
},
|
|
799
|
+
)
|
|
915
800
|
end
|
|
916
801
|
|
|
917
802
|
it 'overwrites fact' do
|
|
918
803
|
add_custom_fact :identity, { 'user' => 'other_user' }
|
|
919
|
-
expect(subject['redhat-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
804
|
+
expect(subject['redhat-9-x86_64'][:identity]).to eq(
|
|
805
|
+
{
|
|
806
|
+
'user' => 'other_user',
|
|
807
|
+
},
|
|
808
|
+
)
|
|
923
809
|
end
|
|
924
810
|
|
|
925
811
|
it 'confines a fact to a particular operating system' do
|
|
926
|
-
add_custom_fact 'root_home', '/root', :
|
|
927
|
-
expect(subject['redhat-
|
|
928
|
-
expect(subject['redhat-
|
|
812
|
+
add_custom_fact 'root_home', '/root', confine: 'redhat-9-x86_64'
|
|
813
|
+
expect(subject['redhat-9-x86_64'][:root_home]).to eq '/root'
|
|
814
|
+
expect(subject['redhat-8-x86_64'][:root_home]).to be_nil
|
|
929
815
|
end
|
|
930
816
|
|
|
931
817
|
it 'excludes a fact from a particular operating system' do
|
|
932
|
-
add_custom_fact 'root_home', '/root', :
|
|
933
|
-
expect(subject['redhat-
|
|
934
|
-
expect(subject['redhat-
|
|
818
|
+
add_custom_fact 'root_home', '/root', exclude: 'redhat-9-x86_64'
|
|
819
|
+
expect(subject['redhat-9-x86_64'][:root_home]).to be_nil
|
|
820
|
+
expect(subject['redhat-8-x86_64'][:root_home]).to eq '/root'
|
|
935
821
|
end
|
|
936
822
|
|
|
937
823
|
it 'takes a proc as a value' do
|
|
938
824
|
add_custom_fact 'root_home', ->(_os, _facts) { '/root' }
|
|
939
|
-
expect(subject['redhat-
|
|
825
|
+
expect(subject['redhat-9-x86_64'][:root_home]).to eq '/root'
|
|
940
826
|
end
|
|
941
827
|
|
|
942
828
|
it 'accepts sym fact key and stores fact key as sym' do
|
|
943
829
|
add_custom_fact :root_home, ->(_os, _facts) { '/root' }
|
|
944
|
-
expect(subject['redhat-
|
|
830
|
+
expect(subject['redhat-9-x86_64'][:root_home]).to eq '/root'
|
|
945
831
|
end
|
|
946
832
|
end
|
|
947
833
|
|
|
@@ -964,6 +850,7 @@ describe RspecPuppetFacts do
|
|
|
964
850
|
def self.open(*_args)
|
|
965
851
|
self
|
|
966
852
|
end
|
|
853
|
+
|
|
967
854
|
def self.get(*_args)
|
|
968
855
|
'my_version'
|
|
969
856
|
end
|
|
@@ -987,7 +874,7 @@ describe RspecPuppetFacts do
|
|
|
987
874
|
end
|
|
988
875
|
|
|
989
876
|
it 'includes an "mco_version" fact' do
|
|
990
|
-
expect(subject.common_facts).to include(:
|
|
877
|
+
expect(subject.common_facts).to include(mco_version: 'my_version')
|
|
991
878
|
end
|
|
992
879
|
end
|
|
993
880
|
|