Conversation
|
@rogpeppe ptal when you have the chance, this is an implementation proposal for the Eventually checker you proposed |
frankban
left a comment
There was a problem hiding this comment.
This looks awesome, thanks!
I have some questions and comments.
eventually.go
Outdated
| break | ||
| } | ||
| if !i.Next(nil) { | ||
| note("got", got) |
There was a problem hiding this comment.
Can't we trust that the underlying checker already notes the got argument?
There was a problem hiding this comment.
The problem is that the got argument is not noted by the checkers, it's appended to the output by the caller in writeError according to the parameter passed to the Eventually checker, which is a function. So the output will look like this:
got: func () int {...}
want: 42
We need overwrite that and that's why I added it as a note and then changed the logic slightly in writeError to skip any provided argument if they are already in the notes.
| } | ||
|
|
||
| // Write notes if present. | ||
| noteKeys := map[string]bool{} |
This PR proposes one form of an EventuallyChecker, which allows asserting eventually (i.e. retry for a given period of time until the assertion holds true) and also for stability (i.e. retry for a given period of time during which the assertion should still hold true).
The EventuallyChecker implements the Checker interface so it can be used like any regular checker. It expects as argument a function with no parameters and one return value.
See issue #121.