Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding_test: Compare unmarshalled set in maps #79

Merged
merged 1 commit into from Apr 13, 2021

Conversation

amorenoz
Copy link
Collaborator

Golang's maps do not have any order guarantee when copying or iterating.
That's not usually a problem when you compare their JSON representations
because assert.JSONEq uses reflect.DeepEqual which takes this into
account

However, in this case, the unmarshalled represetation of the map is
actually a slice, whose ordering does matter.

Therefore, a more robust comparison would be to use
assert.ElementsMatch()

Fixes #73

Signed-off-by: Adrian Moreno amorenoz@redhat.com

Golang's maps do not have any order guarantee when copying or iterating.
That's not usually a problem when you compare their JSON representations
because assert.JSONEq uses reflect.DeepEqual which takes this into
account

However, in this case, the unmarshalled represetation of the map is
actually a slice, whose ordering does matter.

Therefore, a more robust comparison would be to use
assert.ElementsMatch()

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
@coveralls
Copy link

Coverage Status

Coverage remained the same at 76.932% when pulling 3edcf15 on amorenoz:encoding into f72596d on socketplane:main.

Copy link
Collaborator

@dave-tucker dave-tucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dave-tucker dave-tucker merged commit 7b61d43 into ovn-org:main Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix test failures in encoding_test.go
3 participants