Skip to content

Commit

Permalink
Fix TestOkWithRetry unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
tonerdo committed Mar 11, 2022
1 parent c24aa60 commit a2a9abb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/http-helper/http_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,15 @@ func HTTPDoWithRetryWithOptionsE(
t testing.TestingT, options HttpDoOptions, expectedStatus int,
retries int, sleepBetweenRetries time.Duration,
) (string, error) {
// The request body is closed after a request is complete. options.
// Extract the underlying data and cache it so we can reuse for retried requests
data, err := io.ReadAll(options.Body)
options.Body = nil

out, err := retry.DoWithRetryE(
t, fmt.Sprintf("HTTP %s to URL %s", options.Method, options.Url), retries,
sleepBetweenRetries, func() (string, error) {
options.Body = bytes.NewReader(data)
statusCode, out, err := HTTPDoWithOptionsE(t, options)
if err != nil {
return "", err
Expand Down

0 comments on commit a2a9abb

Please sign in to comment.