Improve error message when WaitUntil fails. (#1723)

This commit is contained in:
David Zhao
2023-05-18 14:10:40 -07:00
committed by GitHub
parent 5f3ea75a1e
commit 93d6651d60
+3 -3
View File
@@ -4,8 +4,6 @@ import (
"context"
"testing"
"time"
"github.com/stretchr/testify/require"
)
var (
@@ -19,7 +17,9 @@ func WithTimeout(t *testing.T, f func() string) {
for {
select {
case <-ctx.Done():
require.Empty(t, lastErr)
if lastErr != "" {
t.Fatalf("did not reach expected state after %v: %s", ConnectTimeout, lastErr)
}
case <-time.After(10 * time.Millisecond):
lastErr = f()
if lastErr == "" {