Skip to content

Commit eef69a0

Browse files
alexjfisherb4ldr
authored andcommitted
(PUP-11752) Fix fqdn_rand_string_spec.rb test
Since Puppet `7.23.0` `fqdn_rand` uses the modern structured `networking` fact instead of the legacy `fqdn` fact. In this commit we mock the new fact if using `7.23.0` or later. This is a rebase of puppetlabs#1294 and incorporates Aria Li's original change and a variation on Josh Cooper's suggestion for keeping compatibility with Puppet < `7.23.0`
1 parent a09441b commit eef69a0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

spec/functions/fqdn_rand_string_spec.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ def fqdn_rand_string(max, args = {})
5757

5858
# workaround not being able to use let(:facts) because some tests need
5959
# multiple different hostnames in one context
60-
allow(scope).to receive(:lookupvar).with('::fqdn', {}).and_return(host)
60+
if Gem::Version.new(Puppet::PUPPETVERSION) < Gem::Version.new('7.23.0')
61+
allow(scope).to receive(:lookupvar).with('::fqdn', {}).and_return(host)
62+
else
63+
allow(scope).to receive(:lookupvar).with('facts', {}).and_return({ 'networking' => { 'fqdn' => host } })
64+
end
6165

6266
function_args = [max]
6367
if args.key?(:charset) || !extra.empty?

0 commit comments

Comments
 (0)