sebdah / goldie

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

.Contains()-type functionality? #27

Closed danawoodman closed 1 year ago

danawoodman commented 4 years ago

Would it be possible to have a .Contains() method that would check just part of the golden file? I have a golden file where some parts will change (like generic help text from a CLI) and all I really want to check for is "success" or similar.

I know that means its not really using the golden file but it would make the test less fragile.

Thoughts?

gtrevg commented 4 years ago

@danawoodman I think maybe the right design would be to add a WithCompareFn option that allows you to pass in your own compare function. The comparison lines

would then call the compare function. That way, you could override how it does a comparison between the actualData and the expectedData (which could just do a substring comparison in your case).