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

Unit tests: use go-cmp instead of go-test/deep #517

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

kmoe
Copy link
Member

@kmoe kmoe commented Mar 15, 2022

A cmp.Diff call using exportEverything is equivalent in diffing function to a call to reflect.DeepEqual, the difference for testing purposes being the readability of the diff string.
Combining diffing and formatting into one call eliminates the need for go-test/deep and go-spew.

Still working out some bits and pieces with cty values and float precision.

@kmoe kmoe self-assigned this Mar 15, 2022
@apparentlymart
Copy link
Member

This seems like a nice idea to me! I originally wrote most of these things before I knew about go-cmp, or possibly before it existed... not sure. But I generally like it a lot more than the "deep" thing.

It might be helpful to mix in ctydebug.CmpOptions here, which are some additional go-cmp options to help it understand how to compare cty.Value and cty.Type, by converting them into data structures that are more reflection-friendly.

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.

None yet

2 participants