Skip to content

Commit

Permalink
Merge pull request #365 from atombender/remove_addresses_from_diff
Browse files Browse the repository at this point in the history
When diffing with spew, use a format that doesn't include pointer addresses
  • Loading branch information
ernesto-jimenez authored Nov 17, 2016
2 parents 976c720 + cbd71e7 commit 18a02ba
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
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.

0 comments on commit 18a02ba

Please sign in to comment.