This patch introduces the type OptionValueList in the object package. This new type simplifies working with []vimtypes.BaseOptionValue properties such as ExtraConfig.
Closes: NA
Type of change
Please mark options that are relevant:
[ ] Bug fix (non-breaking change which fixes an issue)
[x] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
[ ] This change requires a documentation update
[ ] Build related change
How Has This Been Tested?
[x] Running go test -v -count 1 -run TestOptionValueList ./object:
=== RUN TestOptionValueList
=== RUN TestOptionValueList/OptionValueListFromMap
=== RUN TestOptionValueList/OptionValueListFromMap/a_nil_map_should_return_nil
=== RUN TestOptionValueList/OptionValueListFromMap/a_map_with_string_values_should_return_OptionValues
=== RUN TestOptionValueList/OptionValueListFromMap/a_map_with_values_of_varying_numeric_types_should_return_OptionValues
=== RUN TestOptionValueList/OptionValueListFromMap/a_map_with_pointer_values_should_return_OptionValues
=== RUN TestOptionValueList/Get
=== RUN TestOptionValueList/Get/a_nil_receiver_should_not_panic_and_return_nil,_false
=== RUN TestOptionValueList/Get/a_non-existent_key_should_return_nil,_false
=== RUN TestOptionValueList/Get/an_existing_key_should_return_its_value,_true
=== RUN TestOptionValueList/Get/an_existing_key_should_return_its_value,_true_when_data_includes_a_nillable_types.BaseOptionValue
=== RUN TestOptionValueList/GetString
=== RUN TestOptionValueList/GetString/a_nil_receiver_should_not_panic_and_return_"",_false
=== RUN TestOptionValueList/GetString/a_non-existent_key_should_return_"",_false
=== RUN TestOptionValueList/GetString/an_existing_key_for_a_string_value_should_return_its_string_value,_true
=== RUN TestOptionValueList/GetString/an_existing_key_for_a_*string_value_that_is_not_nil_should_return_its_string_value,_true
=== RUN TestOptionValueList/GetString/an_existing_key_for_a_*string_value_that_is_nil_should_return_"",_true
=== RUN TestOptionValueList/GetString/an_existing_key_for_an_int32_value_should_return_its_string_value,_true
=== RUN TestOptionValueList/GetString/an_existing_key_for_a_*uint64_value_that_is_not_nil_should_return_its_string_value,_true
=== RUN TestOptionValueList/GetString/an_existing_key_for_a_*uint64_value_that_is_nil_should_return_"",_true
=== RUN TestOptionValueList/GetString/an_existing_key_for_a_string_value_should_return_its_string_value,_true_when_data_includes_a_nillable_types.BaseOptionValue
=== RUN TestOptionValueList/Map
=== RUN TestOptionValueList/Map/a_nil_receiver_should_not_panic_and_return_nil
=== RUN TestOptionValueList/Map/data_with_homogeneous_values_should_return_a_map
=== RUN TestOptionValueList/Map/data_with_heterogeneous_values_should_return_a_map
=== RUN TestOptionValueList/Map/data_with_just_a_nillable_types.BaseOptionValue_should_return_nil
=== RUN TestOptionValueList/StringMap
=== RUN TestOptionValueList/StringMap/a_nil_receiver_should_not_panic_and_return_nil
=== RUN TestOptionValueList/StringMap/data_with_homogeneous_values_should_return_a_map
=== RUN TestOptionValueList/StringMap/data_with_heterogeneous_values_should_return_a_map
=== RUN TestOptionValueList/StringMap/data_with_just_a_nillable_types.BaseOptionValue_should_return_nil
=== RUN TestOptionValueList/Additions
=== RUN TestOptionValueList/Additions/a_nil_receiver_and_nil_input_should_not_panic_and_return_nil
=== RUN TestOptionValueList/Additions/a_nil_receiver_and_non-nil_input_should_not_panic_and_return_the_diff
=== RUN TestOptionValueList/Additions/a_non-nil_receiver_and_nil_input_should_return_nil
=== RUN TestOptionValueList/Additions/a_non-nil_receiver_and_non-nil_input_should_return_the_diff
=== RUN TestOptionValueList/Diff
=== RUN TestOptionValueList/Diff/a_nil_receiver_and_nil_input_should_not_panic_and_return_nil
=== RUN TestOptionValueList/Diff/a_nil_receiver_and_non-nil_input_should_not_panic_and_return_the_diff
=== RUN TestOptionValueList/Diff/a_non-nil_receiver_and_nil_input_should_return_nil
=== RUN TestOptionValueList/Diff/a_non-nil_receiver_and_non-nil_input_should_return_the_diff
=== RUN TestOptionValueList/Join
=== RUN TestOptionValueList/Join/a_nil_receiver_and_nil_input_should_not_panic_and_return_nil
=== RUN TestOptionValueList/Join/a_nil_receiver_and_non-nil_input_should_not_panic_and_return_the_joined_data
=== RUN TestOptionValueList/Join/a_non-nil_receiver_and_nil_input_should_return_the_joined_data
=== RUN TestOptionValueList/Join/a_non-nil_receiver_and_non-nil_input_should_return_the_joined_data
=== RUN TestOptionValueList/Join/a_non-nil_receiver_and_non-nil_input,_flipping_left_and_right,_should_return_the_joined_data
--- PASS: TestOptionValueList (0.00s)
--- PASS: TestOptionValueList/OptionValueListFromMap (0.00s)
--- PASS: TestOptionValueList/OptionValueListFromMap/a_nil_map_should_return_nil (0.00s)
--- PASS: TestOptionValueList/OptionValueListFromMap/a_map_with_string_values_should_return_OptionValues (0.00s)
--- PASS: TestOptionValueList/OptionValueListFromMap/a_map_with_values_of_varying_numeric_types_should_return_OptionValues (0.00s)
--- PASS: TestOptionValueList/OptionValueListFromMap/a_map_with_pointer_values_should_return_OptionValues (0.00s)
--- PASS: TestOptionValueList/Get (0.00s)
--- PASS: TestOptionValueList/Get/a_nil_receiver_should_not_panic_and_return_nil,_false (0.00s)
--- PASS: TestOptionValueList/Get/a_non-existent_key_should_return_nil,_false (0.00s)
--- PASS: TestOptionValueList/Get/an_existing_key_should_return_its_value,_true (0.00s)
--- PASS: TestOptionValueList/Get/an_existing_key_should_return_its_value,_true_when_data_includes_a_nillable_types.BaseOptionValue (0.00s)
--- PASS: TestOptionValueList/GetString (0.00s)
--- PASS: TestOptionValueList/GetString/a_nil_receiver_should_not_panic_and_return_"",_false (0.00s)
--- PASS: TestOptionValueList/GetString/a_non-existent_key_should_return_"",_false (0.00s)
--- PASS: TestOptionValueList/GetString/an_existing_key_for_a_string_value_should_return_its_string_value,_true (0.00s)
--- PASS: TestOptionValueList/GetString/an_existing_key_for_a_*string_value_that_is_not_nil_should_return_its_string_value,_true (0.00s)
--- PASS: TestOptionValueList/GetString/an_existing_key_for_a_*string_value_that_is_nil_should_return_"",_true (0.00s)
--- PASS: TestOptionValueList/GetString/an_existing_key_for_an_int32_value_should_return_its_string_value,_true (0.00s)
--- PASS: TestOptionValueList/GetString/an_existing_key_for_a_*uint64_value_that_is_not_nil_should_return_its_string_value,_true (0.00s)
--- PASS: TestOptionValueList/GetString/an_existing_key_for_a_*uint64_value_that_is_nil_should_return_"",_true (0.00s)
--- PASS: TestOptionValueList/GetString/an_existing_key_for_a_string_value_should_return_its_string_value,_true_when_data_includes_a_nillable_types.BaseOptionValue (0.00s)
--- PASS: TestOptionValueList/Map (0.00s)
--- PASS: TestOptionValueList/Map/a_nil_receiver_should_not_panic_and_return_nil (0.00s)
--- PASS: TestOptionValueList/Map/data_with_homogeneous_values_should_return_a_map (0.00s)
--- PASS: TestOptionValueList/Map/data_with_heterogeneous_values_should_return_a_map (0.00s)
--- PASS: TestOptionValueList/Map/data_with_just_a_nillable_types.BaseOptionValue_should_return_nil (0.00s)
--- PASS: TestOptionValueList/StringMap (0.00s)
--- PASS: TestOptionValueList/StringMap/a_nil_receiver_should_not_panic_and_return_nil (0.00s)
--- PASS: TestOptionValueList/StringMap/data_with_homogeneous_values_should_return_a_map (0.00s)
--- PASS: TestOptionValueList/StringMap/data_with_heterogeneous_values_should_return_a_map (0.00s)
--- PASS: TestOptionValueList/StringMap/data_with_just_a_nillable_types.BaseOptionValue_should_return_nil (0.00s)
--- PASS: TestOptionValueList/Additions (0.00s)
--- PASS: TestOptionValueList/Additions/a_nil_receiver_and_nil_input_should_not_panic_and_return_nil (0.00s)
--- PASS: TestOptionValueList/Additions/a_nil_receiver_and_non-nil_input_should_not_panic_and_return_the_diff (0.00s)
--- PASS: TestOptionValueList/Additions/a_non-nil_receiver_and_nil_input_should_return_nil (0.00s)
--- PASS: TestOptionValueList/Additions/a_non-nil_receiver_and_non-nil_input_should_return_the_diff (0.00s)
--- PASS: TestOptionValueList/Diff (0.00s)
--- PASS: TestOptionValueList/Diff/a_nil_receiver_and_nil_input_should_not_panic_and_return_nil (0.00s)
--- PASS: TestOptionValueList/Diff/a_nil_receiver_and_non-nil_input_should_not_panic_and_return_the_diff (0.00s)
--- PASS: TestOptionValueList/Diff/a_non-nil_receiver_and_nil_input_should_return_nil (0.00s)
--- PASS: TestOptionValueList/Diff/a_non-nil_receiver_and_non-nil_input_should_return_the_diff (0.00s)
--- PASS: TestOptionValueList/Join (0.00s)
--- PASS: TestOptionValueList/Join/a_nil_receiver_and_nil_input_should_not_panic_and_return_nil (0.00s)
--- PASS: TestOptionValueList/Join/a_nil_receiver_and_non-nil_input_should_not_panic_and_return_the_joined_data (0.00s)
--- PASS: TestOptionValueList/Join/a_non-nil_receiver_and_nil_input_should_return_the_joined_data (0.00s)
--- PASS: TestOptionValueList/Join/a_non-nil_receiver_and_non-nil_input_should_return_the_joined_data (0.00s)
--- PASS: TestOptionValueList/Join/a_non-nil_receiver_and_non-nil_input,_flipping_left_and_right,_should_return_the_joined_data (0.00s)
PASS
ok github.com/vmware/govmomi/object 0.306s
[x] Demonstrating 100% code-coverage for the new code:
Checklist:
[x] My code follows the CONTRIBUTIONguidelines of this project
[x] I have commented my code, particularly in hard-to-understand areas
[x] I have made corresponding changes to the documentation
[x] I have added tests that prove my fix is effective or that my feature works
[x] New and existing unit tests pass locally with my changes
Thanks @dougm , I addressed everything. Please note the one length check was to avoid initializing the map unless required. I updated that. Thanks again!
Description
This patch introduces the type
OptionValueList
in theobject
package. This new type simplifies working with[]vimtypes.BaseOptionValue
properties such as ExtraConfig.Closes:
NA
Type of change
Please mark options that are relevant:
How Has This Been Tested?
[x] Running
go test -v -count 1 -run TestOptionValueList ./object
:[x] Demonstrating 100% code-coverage for the new code:
Checklist:
CONTRIBUTION
guidelines of this project