Closed gtrevg closed 5 years ago
@sebdah Thanks for making those updates! It's now been merged into my branch.
Thanks for doing this! I'm just a random person who would probably use this when it lands, so take this with a grain of salt, but a few comments:
Expected[/path/to/template]
) in the FromFile. I can override the diffEngine, obviously, but this seems like a good default@gtrevg Thank you :+1:
@novas0x2a I think those are good comments, good catch on AssertWithTemplate()
!
I'll address the first one in a separate PR that will be merged together with this one when we :ship: to master
.
@novas0x2a Forgot to comment on the second one; Since we don't have the filename handy right now in that function, I suggest we treat that as a separate feature request. I'll create a ticket for it and we can most likely find a nifty way to address it. I think the request itself makes a lot of sense. :bowing_man:
This version of goldie follows the functional options pattern:
https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis
It allows for easy, independent configuration of the goldie object, allowing each test case to leverage different options while running in parallel. In addition to the restructuring, a new
DiffEngine
option was added. This allows you to chooseClassicDiff
orColoredDiff
to see the difference in the golden files, or you could even use theDiffFn
option to implement your own diff function.Errors were also updated to use pointer receivers instead of value receivers. This is the pattern that Go uses internally. In addition, the new
errors
package from Go v1.13 was incorporated. This will require those using this package to compile with Go v1.13 or higher.This PR will close out #8 and #10 .