Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit eb5d664

Browse files
authored
Refactor EventuallyChan (#65)
1 parent 6ab247d commit eb5d664

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

eventually.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@ func Eventually(timeout, interval time.Duration, fn func() FailureMessage) Failu
1717
// EventuallyChan executes the test function until it returns an empty FailureMessage or timeout elapses.
1818
func EventuallyChan[TTimerPayload, TTickPayload any](timeout <-chan (TTimerPayload), ticker <-chan (TTickPayload), fn func() FailureMessage) FailureMessage {
1919
var err string
20-
failMsg := func(cause string) FailureMessage {
20+
fail := func() FailureMessage {
2121
return FailureMessage("function never passed, last failure message:\n" + err)
2222
}
2323

2424
for {
2525
select {
2626
case <-timeout:
27-
return failMsg("timeout")
27+
return fail()
2828
default:
2929
}
3030

3131
err = string(fn())
3232

3333
select {
3434
case <-timeout:
35-
return failMsg("timeout")
35+
return fail()
3636
default:
3737
}
3838

@@ -42,7 +42,7 @@ func EventuallyChan[TTimerPayload, TTickPayload any](timeout <-chan (TTimerPaylo
4242

4343
select {
4444
case <-timeout:
45-
return failMsg("timeout")
45+
return fail()
4646
case <-ticker:
4747
}
4848
}

0 commit comments

Comments
 (0)