Skip to content
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

Testing http.Client.Timeout value with retries #71

Open
danielbh opened this issue Jul 23, 2020 · 0 comments
Open

Testing http.Client.Timeout value with retries #71

danielbh opened this issue Jul 23, 2020 · 0 comments

Comments

@danielbh
Copy link

danielbh commented Jul 23, 2020

Hello,

Great lib!

I'm trying to test retries with a specific http.Client.Timeout value. Response.Delay does not seem to work as expected. I set it to 60 and I set my http.Client.Timeout to 5. My retries are also set to retry after Client.Timeout. When I do this and run the following test it does not seem to timeout as expected. What I expect to happen is to retry twice after a maximum of 5 seconds per request. What happens instead is the test takes much longer to run. Any idea of a workaround or area of the gock code that might change to make this work? Happy to submit a PR for this with your guidance. Thanks.

         gock.New(url).
		Post("/endpoint").
		Response.
		Delay(60 * time.Second)

          gock.New(url).
		Post("/endpoint").
		Response.
		Delay(60 * time.Second)


	gock.New(url).
		Post("/endpoint").
		MatchHeaders(expectedRequestHeaders).
		Reply(http.StatusCreated)

	client := CreateHTTClientAdapter()
	gock.InterceptClient(client.GetHTTPClient())
        resp,err := client.Post(generateBody(), test.CreateStandardHeaders())

	assert.Nil(suite.T(), err, "err should be nil and should handle error through response")
	assert.Equal(suite.T(), http.StatusCreated, resp.Status, "status should be 201/Created")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant