sebdah / goldie

Golden file testing for Go
MIT License
228 stars 19 forks source link

Restructuring of package plus diff generation and new errors #15

Closed gtrevg closed 5 years ago

gtrevg commented 5 years ago

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 choose ClassicDiff or ColoredDiff to see the difference in the golden files, or you could even use the DiffFn 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 .

gtrevg commented 5 years ago

@sebdah Thanks for making those updates! It's now been merged into my branch.

novas0x2a commented 5 years ago

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:

sebdah commented 5 years ago

@gtrevg Thank you :+1:

sebdah commented 5 years ago

@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.

sebdah commented 5 years ago

@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: