New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to determine the duration before retry according the retry number #772
Allow to determine the duration before retry according the retry number #772
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a nice feature! I think we can implement some methods in terms of others but it's otherwise all good. If you can do those 2 changes I'll merge next. Do you need a release soon?
/** @return a result that is retried at least 40 times until it's ok */ | ||
def eventually[T : AsResult](result: =>T): T = | ||
eventually(40, 100.millis)(result) | ||
eventually(40, (_: Int) => 100.millis)(result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to write eventually(40, 100.millis)(result)
here, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, just prefer to directly call the more primitive variant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, that's fine. On the other hand most of the tests are not passing. Could you please investigate why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
if (retries <= 1) { | ||
r | ||
def eventually[T : AsResult](retries: Int, sleep: Int => Duration)(result: =>T): T = { | ||
@annotation.tailrec def retry(retried: Int): T = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good naming change 👍
|
||
/** @return a matcher that will retry the nested matcher 40 times */ | ||
def eventually[T](nested: =>Matcher[T]): Matcher[T] = eventually(nested, 40, 100.millis) | ||
def eventually[T](nested: =>Matcher[T]): Matcher[T] = eventually(nested, 40, (_: Int) => 100.millis) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you should also be able to call eventually(nested, 40, 100.millis)
directly
270259a
to
2990bb8
Compare
2990bb8
to
b62fb2f
Compare
All tests passing indeed, thanks! |
Thx @etorreborre for the quick review |
Usage: