Skip to content

Commit e967115

Browse files
authored
Merge pull request #9523 from mhashizume/maint/main/test-fixes
JSON and URI updates
2 parents 4224d1d + 295d2f9 commit e967115

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

lib/puppet/face/facts.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,15 @@
167167

168168
case result
169169
when Array, Hash
170-
Puppet::Util::Json.dump(result, :pretty => true)
170+
# JSON < 2.8.0 would pretty print empty arrays and hashes with newlines
171+
# Maintain that behavior for our users for now
172+
if result.is_a?(Array) && result.empty?
173+
"[\n\n]"
174+
elsif result.is_a?(Hash) && result.empty?
175+
"{\n}"
176+
else
177+
Puppet::Util::Json.dump(result, :pretty => true)
178+
end
171179
else # one of VALID_TYPES above
172180
result
173181
end

spec/unit/application/facts_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191

9292
{
9393
"type_hash" => [{'a' => 2}, "{\n \"a\": 2\n}"],
94+
"type_empty_hash" => [{}, "{\n}"],
9495
"type_array" => [[], "[\n\n]"],
9596
"type_string" => ["str", "str"],
9697
"type_int" => [1, "1"],

spec/unit/provider/package/puppetserver_gem_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777

7878
it "raises if given an invalid URI" do
7979
resource[:source] = 'h;ttp://rubygems.com'
80-
expect { provider.install }.to raise_error(Puppet::Error, /Invalid source '': bad URI\(is not URI\?\)/)
80+
expect { provider.install }.to raise_error(Puppet::Error, /Invalid source '': bad URI \(is not URI\?\)/)
8181
end
8282
end
8383
end

0 commit comments

Comments
 (0)