diff options
author | Lamont Granquist <lamont@chef.io> | 2020-09-04 13:58:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-04 13:58:39 -0700 |
commit | f96de160e24357a86d766ba0e0f88cbcd48106dc (patch) | |
tree | 45a35ea1c8a59f6cb47ec2acced2f9a4ea8c0782 /spec | |
parent | 90083e3ba82161d9f202f0d0c4bde4965c54b72f (diff) | |
parent | f8189e22d767ff2e5ccf5f906f5f88652627bb34 (diff) | |
download | chef-f96de160e24357a86d766ba0e0f88cbcd48106dc.tar.gz |
Merge pull request #10382 from chef/lcg/fix-nil-deep-merge
Signed-off-by: Lamont Granquist <lamont@chef.io>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/mixin/deep_merge_spec.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/unit/mixin/deep_merge_spec.rb b/spec/unit/mixin/deep_merge_spec.rb index 2122008616..c6681b3d16 100644 --- a/spec/unit/mixin/deep_merge_spec.rb +++ b/spec/unit/mixin/deep_merge_spec.rb @@ -236,6 +236,14 @@ describe Chef::Mixin::DeepMerge, "deep_merge!" do @dm.deep_merge!(hash_src, hash_dst) expect(hash_dst).to eq({ "item" => "orange" }) end + + it "should overwrite a string with a nil when merging nil values" do + hash_src = { "item" => nil } + hash_dst = { "item" => "orange" } + @dm.deep_merge!(hash_src, hash_dst) + expect(hash_dst).to eq({ "item" => nil }) + end + end # deep_merge! # Chef specific @@ -338,5 +346,12 @@ describe Chef::Mixin::DeepMerge do merge_with_hash = { "top_level_a" => 2, "top_level_b" => true } @dm.hash_only_merge(merge_ee_hash, merge_with_hash) end + + it "should overwrite a string with a nil when merging nil values" do + hash_src = { "item" => nil } + hash_dst = { "item" => "orange" } + merged_result = @dm.hash_only_merge(hash_dst, hash_src) + expect(merged_result).to eq({ "item" => nil }) + end end end |