Skip to content

Add config options AlwaysIncludeTrailingComma, DisableNilValues#60

Open
atombender wants to merge 2 commits intodavecgh:masterfrom
atombender:disable_nils
Open

Add config options AlwaysIncludeTrailingComma, DisableNilValues#60
atombender wants to merge 2 commits intodavecgh:masterfrom
atombender:disable_nils

Conversation

@atombender
Copy link
Copy Markdown
Contributor

Adds config option AlwaysIncludeTrailingComma, which forces the writing of commas in arrays/slices/maps. Useful in tests to avoid false positives when diffing. This is a prerequisite to resolving this Testify issue.

Building on that commit is a new config option DisableNilValues. Background: We have a bunch of tests that use Spew to generate "golden" test data. This is great, but often one adds a new, optional field to a struct that's part of this data, and suddenly all the test data is broken because the new filed is nil everywhere. It's onerous to update all test data for such zero-value fields. This fixes that.

…g of commas

in arrays/slices/maps. Useful in tests to avoid false positives when diffing.
…o include

nil fields. This is useful in tests that rely on "golden" test data: Often one
adds a new, optional field to a struct, and it's onerous to update all test
data to reflect this field, which would now be nil everywhere.
@atombender
Copy link
Copy Markdown
Contributor Author

Oh, and this fixes #54.

@atombender
Copy link
Copy Markdown
Contributor Author

@davecgh Thoughts? I was thinking of changing the nil functionality to disable all zero values, which will cover more use cases.

@kmudrick kmudrick mentioned this pull request Apr 6, 2018
@kmudrick
Copy link
Copy Markdown

kmudrick commented Apr 6, 2018

I really like the DisableNilValues option

@georgelesica-wf
Copy link
Copy Markdown

@davecgh do you think we could move this along? It would help us resolve stretchr/testify#288. Or, if it's not going to happen, we can just close that or maybe try to fix it on our end. Either way works for me.

@maxatome
Copy link
Copy Markdown

For the DisableNilValues I think #77 is better suited as it covers all zero cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants