Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When diffing with spew, use a format that doesn't include pointer addresses #365

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions assert/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ import (
"github.com/pmezard/go-difflib/difflib"
)

func init() {
spew.Config.SortKeys = true
}

// TestingT is an interface wrapper around *testing.T
type TestingT interface {
Errorf(format string, args ...interface{})
Expand Down Expand Up @@ -1043,8 +1039,8 @@ func diff(expected interface{}, actual interface{}) string {
return ""
}

e := spew.Sdump(expected)
a := spew.Sdump(actual)
e := spewConfig.Sdump(expected)
a := spewConfig.Sdump(actual)

diff, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
A: difflib.SplitLines(e),
Expand All @@ -1058,3 +1054,10 @@ func diff(expected interface{}, actual interface{}) string {

return "\n\nDiff:\n" + diff
}

var spewConfig = spew.ConfigState{
Indent: " ",
DisablePointerAddresses: true,
DisableCapacities: true,
SortKeys: true,
}
15 changes: 9 additions & 6 deletions mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ import (
"github.com/stretchr/testify/assert"
)

func inin() {
spew.Config.SortKeys = true
}

// TestingT is an interface wrapper around *testing.T
type TestingT interface {
Logf(format string, args ...interface{})
Expand Down Expand Up @@ -746,8 +742,8 @@ func diff(expected interface{}, actual interface{}) string {
return ""
}

e := spew.Sdump(expected)
a := spew.Sdump(actual)
e := spewConfig.Sdump(expected)
a := spewConfig.Sdump(actual)

diff, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
A: difflib.SplitLines(e),
Expand All @@ -761,3 +757,10 @@ func diff(expected interface{}, actual interface{}) string {

return diff
}

var spewConfig = spew.ConfigState{
Indent: " ",
DisablePointerAddresses: true,
DisableCapacities: true,
SortKeys: true,
}
9 changes: 9 additions & 0 deletions vendor/github.com/davecgh/go-spew/spew/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vendor/github.com/davecgh/go-spew/spew/dump.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.