Merge pull request #539 from mentat/MODULES-2696
Add check to ensure regex does not throw for none type.
This commit is contained in:
commit
39126a7bc8
2 changed files with 19 additions and 2 deletions
|
@ -10,8 +10,13 @@
|
||||||
#
|
#
|
||||||
Facter.add("pe_version") do
|
Facter.add("pe_version") do
|
||||||
setcode do
|
setcode do
|
||||||
pe_ver = Facter.value("puppetversion").match(/Puppet Enterprise (\d+\.\d+\.\d+)/)
|
puppet_ver = Facter.value("puppetversion")
|
||||||
pe_ver[1] if pe_ver
|
if puppet_ver != nil
|
||||||
|
pe_ver = puppet_ver.match(/Puppet Enterprise (\d+\.\d+\.\d+)/)
|
||||||
|
pe_ver[1] if pe_ver
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,17 @@ describe "PE Version specs" do
|
||||||
Facter.collection.loader.load(:pe_version)
|
Facter.collection.loader.load(:pe_version)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "When puppetversion is nil" do
|
||||||
|
before :each do
|
||||||
|
Facter.fact(:puppetversion).stubs(:value).returns(nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "pe_version is nil" do
|
||||||
|
expect(Facter.fact(:puppetversion).value).to be_nil
|
||||||
|
expect(Facter.fact(:pe_version).value).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "If PE is installed" do
|
context "If PE is installed" do
|
||||||
%w{ 2.6.1 2.10.300 }.each do |version|
|
%w{ 2.6.1 2.10.300 }.each do |version|
|
||||||
|
@ -73,4 +84,5 @@ describe "PE Version specs" do
|
||||||
expect(Facter.fact(:pe_patch_version).value).to be_nil
|
expect(Facter.fact(:pe_patch_version).value).to be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue