httpexpect
httpexpect copied to clipboard
Add `WithRetryHandler` for a custom `RetryPolicy`
Context: My test is as simple as:
e.GET("/nginx").
WithMaxRetries(10).
WithRetryDelay(time.Second, time.Second*2).
WithRetryPolicy(httpexpect.RetryAllErrors).
Expect().
Status(http.StatusNotFound).
Body().Contains(`nginx/`)
I'm expecting a dynamic result from one call to the other. And I'd like to handle the retry policy myself here. Whuch does not seems doable right now.
So something like:
e.GET("/nginx").
WithMaxRetries(10).
WithRetryDelay(time.Second, time.Second*2).
WithRetryPolicy(httpexpect.RetryAllErrors).
WithRetryHandler(func(resp *http.Response, err error) bool {
// Check body if available, etc.
return ...
})
Expect().
Status(http.StatusNotFound).
Body().Contains(`nginx/`)
What do you think ?