Closed grosser closed 1 month ago
hey - this makes sense, though really only for Consistently
. I'll implement StopTrying(...).Success()
but will have it error if you use it with Eventually
but do what you're describing fro Consistently
.
thx! :D yeah it would be weird for eventually
do you mind if I use your example in the docs?
go ahead 👍
alrighty, this is pushed now. will cut a release oon
thank you 🎉
FYI using this wrapper
func ConsistentlyUntil[T any](fn func() T, timeout any, interval any, errChan chan error) AsyncAssertion {
return Consistently(func() T {
select {
case err := <-errChan:
if err == nil {
StopTrying("success!").Successfully().Now()
}
StopTrying(fmt.Sprintf("background task faild: %v", err)).Now()
return fn() // unreachable since StopTrying will panic
default:
return fn()
}
}, timeout, interval)
}
ooh that's nice. glad it's proven useful :)
as per https://onsi.github.io/gomega/#bailing-out-early
StopTrying
is the only way to stop iteration without having to implement a custom matcher but I'd like to also stop with a success, for exampleto not fail, for example with
StopTrying("background task stopped").Success()
or returnreturn true, StopTrying("background task stopped").Success()