hcl icon indicating copy to clipboard operation
hcl copied to clipboard

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

Open kmoe opened this issue 3 years ago • 1 comments

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 avatar Mar 15 '22 18:03 kmoe

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.

apparentlymart avatar Mar 16 '22 21:03 apparentlymart