gotestyourself / gotest.tools

A collection of packages to augment the go testing package and support common patterns.
https://gotest.tools/v3
Other
513 stars 50 forks source link

assert: golden variables #237

Closed dnephin closed 2 years ago

dnephin commented 2 years ago

This PR adds a second option for golden values. The golden package allows storing of expected values in files. The approach in this PR would allow storing the golden value in a package-level variable.

Initially I think support for this should be limited to only package-level variables of type string, but I think it would be possible to expand the support in the future.

I updated the internal uses of golden to use this new way of storing values, and the test cases show another couple examples.