Fix tests

This commit is contained in:
Tom Wilkie
2016-01-23 11:54:22 -08:00
parent b8daa02488
commit 41d48224aa
4 changed files with 9 additions and 4 deletions

View File

@@ -1,13 +1,13 @@
package app_test
import (
"reflect"
"testing"
"time"
"github.com/weaveworks/scope/app"
"github.com/weaveworks/scope/report"
"github.com/weaveworks/scope/test"
"github.com/weaveworks/scope/test/reflect"
)
func TestCollector(t *testing.T) {

View File

@@ -4,12 +4,12 @@ import (
"compress/gzip"
"encoding/gob"
"io"
"reflect"
"testing"
"time"
"github.com/weaveworks/scope/report"
"github.com/weaveworks/scope/test"
"github.com/weaveworks/scope/test/reflect"
)
func TestApply(t *testing.T) {

View File

@@ -83,8 +83,10 @@ type Report struct {
Shortcut bool
// ID a random identifier for this report, used when caching
// rendered views of the report
ID string
// rendered views of the report. Reports with the same id
// must be equal, but we don't require that equal reports have
// the same id.
ID string `deepequal:"skip"`
}
// MakeReport makes a clean report, ready to Merge() other reports into.

View File

@@ -105,6 +105,9 @@ func deepValueEqual(v1, v2 reflect.Value, visited map[visit]bool, depth int) boo
return deepValueEqual(v1.Elem(), v2.Elem(), visited, depth+1)
case reflect.Struct:
for i, n := 0, v1.NumField(); i < n; i++ {
if v1.Type().Field(i).Tag.Get("deepequal") == "skip" {
continue
}
if !deepValueEqual(v1.Field(i), v2.Field(i), visited, depth+1) {
return false
}