Skip to content

Commit

Permalink
return early in Eventually and EventuallyWithT
Browse files Browse the repository at this point in the history
  • Loading branch information
cszczepaniak committed Jul 15, 2023
1 parent af4d8a6 commit 656b9dd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions assert/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,10 @@ func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick t
h.Helper()
}

if condition() {
return true
}

ch := make(chan bool, 1)

timer := time.NewTimer(waitFor)
Expand Down Expand Up @@ -1913,6 +1917,13 @@ func EventuallyWithT(t TestingT, condition func(collect *CollectT), waitFor time
}

collect := new(CollectT)

condition(collect)
if len(collect.errors) == 0 {
return true
}
collect.Reset()

ch := make(chan bool, 1)

timer := time.NewTimer(waitFor)
Expand Down

0 comments on commit 656b9dd

Please sign in to comment.