mirror of
https://github.com/weaveworks/scope.git
synced 2026-02-18 20:10:02 +00:00
By default, tests should be in package pkg_test. If they need to test package internals, they can be in package pkg, but then should carry a suffix of foo_internal_test.go. This changeset enforces that idiom across the codebase, and adds a check to the linter to make sure it remains. Also, some fixes to comments.
23 lines
515 B
Go
23 lines
515 B
Go
package test
|
|
|
|
import (
|
|
"github.com/davecgh/go-spew/spew"
|
|
"github.com/pmezard/go-difflib/difflib"
|
|
)
|
|
|
|
func init() {
|
|
spew.Config.SortKeys = true // :\
|
|
}
|
|
|
|
// Diff diffs two arbitrary data structures, giving human-readable output.
|
|
func Diff(want, have interface{}) string {
|
|
text, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
|
|
A: difflib.SplitLines(spew.Sdump(want)),
|
|
B: difflib.SplitLines(spew.Sdump(have)),
|
|
FromFile: "want",
|
|
ToFile: "have",
|
|
Context: 3,
|
|
})
|
|
return "\n" + text
|
|
}
|