Closed franiglesias closed 9 months ago
After reading this, I think I could go this way for current test options
And this
So, api could be something like:
golden.Verify(t, subject, Options().UseScrubber(NewDateScrubber()))
Options() should be able to handle all options that apply to a specific test.
Options().UseScrubber()
Options().UseSnapshot()
Options().InFolder()
Options().WithExt()
Options().UseReporter()
Internally, Options should resolve to a complete set of options. Something like this constructor that should create a new Options merging the data received with a new options object
testOptions := CloneOptions(receivedOptions)
We are going with the functional Options pattern. For Scrubeers we could have an Option function able to pass a list of Scrubbers to use
Also, we should differentiate scrubbers from filters. For example, filters could clean subject Itrim... etc)
Manage not deterministic data using scrubbers.
Scrubbers can work using regexp to locate specific info and replace with a static representation. It could be something like "removed for testing", or maybe a valid example of data, but I thing it should be marked some way. This can be a problem if we want to use the snapshot as an example.
We should be able to pass any number of scrubbers.
We should be able to ask for predefined scrubbers, because there are lots of common cases.
The place for scrubbing should be the Normalizer.