diff --git a/platform/wait/wait.go b/platform/wait/wait.go index 987dae54..d0c078b8 100644 --- a/platform/wait/wait.go +++ b/platform/wait/wait.go @@ -1,6 +1,7 @@ package wait import ( + "errors" "fmt" "time" @@ -16,6 +17,9 @@ func For(msg string, timeout, interval time.Duration, f func() (bool, error)) er for { select { case <-timeUp: + if lastErr == nil { + return errors.New("time limit exceeded") + } return fmt.Errorf("time limit exceeded: last error: %w", lastErr) default: } diff --git a/platform/wait/wait_test.go b/platform/wait/wait_test.go index e87f055e..9722e6f2 100644 --- a/platform/wait/wait_test.go +++ b/platform/wait/wait_test.go @@ -13,7 +13,7 @@ func TestForTimeout(t *testing.T) { }) }() - timeout := time.After(5 * time.Second) + timeout := time.After(6 * time.Second) select { case <-timeout: t.Fatal("timeout exceeded") @@ -21,5 +21,6 @@ func TestForTimeout(t *testing.T) { if err == nil { t.Errorf("expected timeout error; got %v", err) } + t.Logf("%v", err) } }