Make spew config selection configurable to allow for helpful diffs on time.Time objects nested in structs. #1079
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Make time.Time objects nested inside structs produce reasonable diffs by making spewConfig configurable
Changes
#895 had some unintended side-effects on what diffs of
time.Time
look like: see #1078.This attempts to solve the problem by allowing the user to select if they want to use the SpewConfig that has Stringer methods enabled. The default behavior remains the same. But if the user runs their tests after setting the environment variable
TESTIFY_SPEW_STRINGER_ENABLE
toTRUE
, testify will pick the stringer config that does not disable the Stringer methods and thus produces nice diffs for time.Time nested inside structs.This contains a minimal repro of this issue, right now those tests produce an almost 1500 line diff on test failure. After this change and when
TESTIFY_SPEW_STRINGER_ENABLE
env var is set toTRUE
it will produce a user friendly diff like:Motivation
Please see #1078 which describes the issue in detail
export TESTIFY_SPEW_STRINGER_ENABLE=TRUE && go test ./...
Related issues
#1078