httpexpect icon indicating copy to clipboard operation
httpexpect copied to clipboard

Add unit tests for redirect and retry support

Open gavv opened this issue 4 years ago • 7 comments

Redirect methods (WithRedirectPolicy, WithMaxRedirects) and retry methods (WithRetryPolicy, WithMaxRetries, WithRetryDelay) are already covered with end-to-end tests (e2e_redirect_test.go, e2e_retry_test.go), but unit tests are missing.

It would be nice to add unit tests for these methods to request_test.go. Those unit tests use mockClient to inspect generated http.Requests.

gavv avatar Feb 20 '21 20:02 gavv

@gavv could I make a PR to add these tests?

gopalanvinay avatar Feb 26 '21 08:02 gopalanvinay

@gopalanvinay Sure, you're welcome.

gavv avatar Feb 27 '21 14:02 gavv

Is this issue still open?

123vivekr avatar Aug 12 '21 09:08 123vivekr

@123vivekr Hi! Yes, there is unmerged PR with unresolved issues, see #94. Feel free to pick up the task.

gavv avatar Aug 18 '21 09:08 gavv

Thank you! I'm a beginner in Golang. I'll give this a try and submit a PR for review soon.

123vivekr avatar Aug 21 '21 10:08 123vivekr

Hi @gavv is it still open? If so, I would like to pick it up. Although, looks like #94 is ready to be merged already.

kaustubhmallik avatar Jan 19 '22 16:01 kaustubhmallik

@kaustubhmallik Feel free to take it up. I'm not working on it

123vivekr avatar Jan 19 '22 16:01 123vivekr

Hi, the issue is still open. See also discussion in #94.

gavv avatar Nov 13 '22 08:11 gavv

@gavv hi, for testing the WithRetryDelay wdyt if we do time.Sleep in the unit test? then assert if the total sleep time is as expected

or you might have concerns about this?

my concern is that by doing sleep, the unit test will be slower by some miliseconds (approximately, because we sleep)

rafiramadhana avatar Nov 29 '22 00:11 rafiramadhana

I think short sleeps, maybe below 10-20 ms per test, are OK.

gavv avatar Nov 29 '22 08:11 gavv

got it, will keep the sleep around that

rafiramadhana avatar Nov 29 '22 15:11 rafiramadhana

Landed

gavv avatar Dec 10 '22 22:12 gavv