MCPcopy
hub / github.com/nats-io/nats.go / checkFor

Function checkFor

test/js_test.go:6595–6609  ·  view source on GitHub ↗
(t *testing.T, totalWait, sleepDur time.Duration, f func() error)

Source from the content-addressed store, hash-verified

6593}
6594
6595func checkFor(t *testing.T, totalWait, sleepDur time.Duration, f func() error) {
6596 t.Helper()
6597 timeout := time.Now().Add(totalWait)
6598 var err error
6599 for time.Now().Before(timeout) {
6600 err = f()
6601 if err == nil {
6602 return
6603 }
6604 time.Sleep(sleepDur)
6605 }
6606 if err != nil {
6607 t.Fatal(err.Error())
6608 }
6609}
6610
6611func checkSubsPending(t *testing.T, sub *nats.Subscription, numExpected int) {
6612 t.Helper()

Calls 2

AddMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected