Skip to content

chore: Replace reflect.DeepEqual with cmp.Equal in tests #3691

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jferrl
Copy link
Contributor

@jferrl jferrl commented Aug 18, 2025

This PR refactors the test suite to replace all instances of reflect.DeepEqual with cmp.Equal from the github.com/google/go-cmp/cmp package. This change improves test performance, provides better error messages, and follows modern Go testing best practices. Also improves test output readability and consistency across the codebase

Updated multiple test files to use github.com/google/go-cmp/cmp.Equal instead of reflect.DeepEqual for value comparisons. This improves test output readability and consistency across the codebase.
@gmlewis
Copy link
Contributor

gmlewis commented Aug 18, 2025

@jferri - just FYI - I lost write access to this repo and this may cause unexpected delays for which I apologize.
You can watch that other PR to check on the status.

@jferrl
Copy link
Contributor Author

jferrl commented Aug 18, 2025

@jferri - just FYI - I lost write access to this repo and this may cause unexpected delays for which I apologize. You can watch that other PR to check on the status.

No worries! 😃

Copy link
Contributor

@alexandear alexandear left a comment

Choose a reason for hiding this comment

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

I propose configuring the forbidigo linter in the golangci-lint config to forbid the use of reflect.DeepEqual in tests. This way, the use of cmp.Equal will be automatically enforced in the future.

Configured the forbidigo linter in .golangci.yml to forbid the use of reflect.DeepEqual, recommending cmp.Equal instead. This helps ensure more reliable equality checks in the codebase.
@jferrl jferrl requested a review from alexandear August 19, 2025 07:27
@jferrl
Copy link
Contributor Author

jferrl commented Aug 19, 2025

I propose configuring the forbidigo linter in the golangci-lint config to forbid the use of reflect.DeepEqual in tests. This way, the use of cmp.Equal will be automatically enforced in the future.

Thanks for the suggestion, good catch 😃

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.

3 participants