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

refactor: Extract assert package from existing tests #91

Merged
merged 2 commits into from
Sep 11, 2024
Merged

Conversation

jdkaplan
Copy link
Collaborator

After the third copy-paste of assertEqual, I think it's time to make an internal test assertion library.

This is similar to testify's assert package, mostly because it's the one I'm most familiar with.

This now uses go-cmp instead of reflect.DeepEqual for comparing values. We get free diff reports out of it too!

I added the package to a new internal directory to make it clear that this isn't part of the application itself. It also prevents it from being imported from anywhere else, even though there's no reason to import from this module anyway.

After the third copy-paste of assertEqual, I think it's time to make an
internal test assertion library.

This is similar to [testify]'s assert package, mostly because it's the
one I'm most familiar with.

This now uses [go-cmp] instead of `reflect.DeepEqual` for comparing
values. We get free diff reports out of it too!

I added the package to a new `internal` directory to make it clear that
this isn't part of the application itself. It also prevents it from
being imported from anywhere else, even though there's no reason to
import from this module anyway.

[go-cmp]: https://github.com/google/go-cmp
[testify]: https://github.com/stretchr/testify
@jdkaplan jdkaplan requested a review from cceckman September 10, 2024 22:17
zulip/client_test.go Outdated Show resolved Hide resolved
@jdkaplan jdkaplan merged commit 5a24aaa into main Sep 11, 2024
3 checks passed
@jdkaplan jdkaplan deleted the jdk-cmp-testing branch September 11, 2024 01:09
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.

2 participants