plow-technologies / hspec-golden-aeson

Use tests to monitor changes in Aeson serialization
Other
18 stars 4 forks source link

RandomMismatchError option only works in ADT case #18

Open symbiont-anna-savarin opened 2 years ago

symbiont-anna-savarin commented 2 years ago

Setting randomMismatchOption = RandomMismatchError only fails the test in the ADT version of GoldenSpecs.

jonathanknowles commented 2 years ago

I also noticed this issue when using hspec-golden-aeson in our test suite.

Perhaps this is something that we could fix? I would be happy to create a PR.

I suspect the source of the problem is this section of code: https://github.com/plow-technologies/hspec-golden-aeson/blob/61270316e82ba76529c986856382e109c03e6752/src/Test/Aeson/Internal/GoldenSpecs.hs#L110-L114

It looks as though it's not checking the value of the randomMismatchOption setting.

By comparison, the ADT version does make this check, and invokes expectationFailure if the RandomMismatchError option is set:

https://github.com/plow-technologies/hspec-golden-aeson/blob/61270316e82ba76529c986856382e109c03e6752/src/Test/Aeson/Internal/ADT/GoldenSpecs.hs#L122-L125