HewlettPackard / oneview-chef

This project is no longer being developed and has limited support. In the near future this repository will be fully deprecated. Please consider using other OneView projects, such as Terraform and Ansible Collection
https://supermarket.chef.io/cookbooks/oneview
Apache License 2.0
17 stars 15 forks source link

OneviewCookbook::Helper#get_diff with two no-diff hashes returns '\n' #98

Closed tmiotto closed 7 years ago

tmiotto commented 7 years ago

Scenario/Intent

When trying to compare two hashes that has no-diff ( i.e. for each key 'k' in 'a', a[k] == b[k] ) with the OneviewCookbook::Helper#get_diff the result returned is '\n'.

Environment Details

Steps to Reproduce

Use get_diff method with two hashes with no-diff like:

a = { a: 'test', b: 'second' }
b = { a: 'test', c: 'other', b: 'second' }
get_diff(a, b)

Expected Result

get_diff should return ''

Actual Result

get_diff returns '\n'

jsmartt commented 7 years ago

It uses "\n" as the initial string here, and I think I did that so that I could just tack the diff onto the end of the log statement (like this), and not have to repeat myself. We can always just set the default string to an empty string and add a newline before the diff though (or set it to an empty string if recursive_diff returns just \n). That's fine with me :)