Files
8c825caf68 Update dskit for gRPC interface change (#5144)
* Update dskit for gRPC interface change

* Update vendor

* Update vendor

* bump dskit

* update go.sum

* manifest

---------

Co-authored-by: javiermolinar <[email protected]>
2025-05-29 16:12:21 +02:00

25 lines
501 B
Go

package test
import (
"reflect"
"testing"
"time"
)
// Poll repeatedly calls a function until the function returns the correct response or until poll timeout.
func Poll(t testing.TB, d time.Duration, want interface{}, have func() interface{}) {
t.Helper()
deadline := time.Now().Add(d)
for !time.Now().After(deadline) {
if reflect.DeepEqual(want, have()) {
return
}
time.Sleep(d / 100)
}
h := have()
if !reflect.DeepEqual(want, h) {
t.Fatalf("expected %v, got %v", want, h)
}
}