Skip to content

Commit 9cd56b8

Browse files
author
Ciprian Badescu
committed
(MODULES-11244) fix spec tests
adapt spec helpers to keep the existing setup
1 parent 0c53cc3 commit 9cd56b8

File tree

3 files changed

+57
-66
lines changed

3 files changed

+57
-66
lines changed

spec/default_facts.yml

-8
This file was deleted.

spec/spec_helper.rb

+4-7
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111

1212
include RspecPuppetFacts
1313

14-
default_facts = {
15-
puppetversion: Puppet.version,
16-
facterversion: Facter.version,
17-
}
14+
default_facts = {}
1815

1916
default_fact_files = [
2017
File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')),
@@ -31,9 +28,9 @@
3128
end
3229
end
3330

34-
# read default_facts and merge them over what is provided by facterdb
35-
default_facts.each do |fact, value|
36-
add_custom_fact fact, value
31+
# check if default_module_facts is defined and merge them if the case
32+
if @default_module_facts.is_a?(Hash)
33+
default_facts.merge!(@default_module_facts)
3734
end
3835

3936
RSpec.configure do |c|

spec/spec_helper_local.rb

+53-51
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,58 @@
1-
require 'puppetlabs_spec_helper/module_spec_helper'
2-
require 'rspec-puppet-facts'
3-
include RspecPuppetFacts
4-
51
location = File.expand_path('/dev/null')
62

7-
RSpec.configure do |c|
8-
c.default_facts = {
9-
:aio_agent_version => '5.5.10',
10-
:puppetversion => '5.5.10',
11-
:lsbdistrelease => nil,
12-
:is_pe => false,
13-
:platform_tag => nil,
14-
:operatingsystem => nil,
15-
:operatingsystemmajrelease => nil,
16-
:kernelmajversion => nil,
17-
:macosx_productname => nil,
18-
:maxosx_productversion_major => nil,
19-
:rubyplatform => nil,
20-
:puppet_master_server => nil,
21-
:puppet_client_datadir => nil,
22-
:path => nil,
23-
:puppet_agent_appdata => nil,
24-
:system32 => nil,
25-
:fips_enabled => false,
3+
@default_module_facts = {
4+
:aio_agent_version => '5.5.10',
5+
:puppetversion => '5.5.10',
6+
:lsbdistrelease => nil,
7+
:is_pe => false,
8+
:platform_tag => nil,
9+
:operatingsystem => nil,
10+
:operatingsystemmajrelease => nil,
11+
:kernelmajversion => nil,
12+
:macosx_productname => nil,
13+
:maxosx_productversion_major => nil,
14+
:rubyplatform => nil,
15+
:puppet_master_server => nil,
16+
:puppet_client_datadir => nil,
17+
:path => nil,
18+
:puppet_agent_appdata => nil,
19+
:system32 => nil,
20+
:fips_enabled => false,
2621

27-
:puppet_ssldir => "#{location}/ssl",
28-
:puppet_config => "#{location}/puppet.conf",
29-
:puppet_sslpaths => {
30-
'privatedir' => {
31-
'path' => "#{location}/ssl/private",
32-
'path_exists' => true,
33-
},
34-
'privatekeydir' => {
35-
'path' => "#{location}/ssl/private_keys",
36-
'path_exists' => true,
37-
},
38-
'publickeydir' => {
39-
'path' => "#{location}/ssl/public_keys",
40-
'path_exists' => true,
41-
},
42-
'certdir' => {
43-
'path' => "#{location}/ssl/certs",
44-
'path_exists' => true,
45-
},
46-
'requestdir' => {
47-
'path' => "#{location}/ssl/certificate_requests",
48-
'path_exists' => true,
49-
},
50-
'hostcrl' => {
51-
'path' => "#{location}/ssl/crl.pem",
52-
'path_exists' => true,
53-
},
22+
:puppet_ssldir => "#{location}/ssl",
23+
:puppet_config => "#{location}/puppet.conf",
24+
:puppet_sslpaths => {
25+
'privatedir' => {
26+
'path' => "#{location}/ssl/private",
27+
'path_exists' => true,
28+
},
29+
'privatekeydir' => {
30+
'path' => "#{location}/ssl/private_keys",
31+
'path_exists' => true,
32+
},
33+
'publickeydir' => {
34+
'path' => "#{location}/ssl/public_keys",
35+
'path_exists' => true,
36+
},
37+
'certdir' => {
38+
'path' => "#{location}/ssl/certs",
39+
'path_exists' => true,
5440
},
55-
}
41+
'requestdir' => {
42+
'path' => "#{location}/ssl/certificate_requests",
43+
'path_exists' => true,
44+
},
45+
'hostcrl' => {
46+
'path' => "#{location}/ssl/crl.pem",
47+
'path_exists' => true,
48+
},
49+
},
50+
}
51+
52+
RSpec.configure do |c|
53+
c.before :each do
54+
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue, doc: '') do |args|
55+
'2018.1.0'
56+
end
57+
end
5658
end

0 commit comments

Comments
 (0)