MarvinJWendt / testza

Full-featured test framework for Go! Assertions, fuzzing, input testing, output capturing, and much more! 🍕
MIT License
418 stars 21 forks source link

Snapshot saves slice capacities, failing when executing on different machines #184

Closed jamestelfer closed 1 year ago

jamestelfer commented 1 year ago

I have snapshots that have a []byte slice member as part of a struct that is snapshotted. This saves the slice capacity to the snapshot file, resulting in failures when tests run on different machines (as capacity is expanded differently).

For example:

           7| ( 4. -)   Content: ([]uint8) (len=116 cap=128) {
           8| ( 4. +)   Content: ([]uint8) (len=116 cap=116) {

These slices are effectively identical, varying only by capacity.

I'm not sure if this behaviour is desired in general (even though it's not for me) or expected. I'm happy to look at creating a fix, let me know.

Thanks for the really useful library!

jamestelfer commented 1 year ago

The solution to this could be using the DisableCapacities configuration of go-spew. This would obviously affect other users of the library, but I'm not sure that's a bad thing if it's mentioned clearly in the release notes. It just means recreating snapshots.