Files
weave-scope/vendor/github.com/weaveworks/common/test/diff.go
Marcus Cobden 6f17a2961c Update weaveworks/common to d442d08d89b51712ca61de3f7c14e2e218a739d7
Changes:
- Default diff-printer to hide details (#103) - da4c3ff
- Improve logging of http errors (#115) - f5a1710
- Update httpgrpc to match weaveworks/cortex#910 (#117) - 80ff076
- Expose the HTTP server from the server struct. (#118) - 1a7a6b3
- Add HTTP tracing middleware (#119) - d442d08
2018-08-28 11:35:54 +01:00

25 lines
695 B
Go

package test
import (
"github.com/davecgh/go-spew/spew"
"github.com/pmezard/go-difflib/difflib"
)
// Diff diffs two arbitrary data structures, giving human-readable output.
func Diff(want, have interface{}) string {
config := spew.NewDefaultConfig()
// Set ContinueOnMethod to true if you cannot see a difference and
// want to look beyond the String() method
config.ContinueOnMethod = false
config.SortKeys = true
config.SpewKeys = true
text, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
A: difflib.SplitLines(config.Sdump(want)),
B: difflib.SplitLines(config.Sdump(have)),
FromFile: "want",
ToFile: "have",
Context: 3,
})
return "\n" + text
}