mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-02 17:50:39 +00:00
Also - Add more complicated report.json for benchmark - Break up report/topology.go - Implement our own DeepEqual for ps.Map
29 lines
571 B
Go
29 lines
571 B
Go
package test
|
|
|
|
import (
|
|
"runtime"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/weaveworks/scope/test/reflect"
|
|
)
|
|
|
|
// Poll repeatedly evaluates condition until we either timeout, or it suceeds.
|
|
func Poll(t *testing.T, d time.Duration, want interface{}, have func() interface{}) {
|
|
deadline := time.Now().Add(d)
|
|
for {
|
|
if time.Now().After(deadline) {
|
|
break
|
|
}
|
|
if reflect.DeepEqual(want, have()) {
|
|
return
|
|
}
|
|
time.Sleep(d / 10)
|
|
}
|
|
h := have()
|
|
if !reflect.DeepEqual(want, h) {
|
|
_, file, line, _ := runtime.Caller(1)
|
|
t.Fatalf("%s:%d: %s", file, line, Diff(want, h))
|
|
}
|
|
}
|