Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! Enable Client.RateLimits to bypass the rate limit check
  • Loading branch information
sa-spag committed Jun 22, 2021
commit 7da44c395e280b154f250a12858859758a22bfc3
3 changes: 3 additions & 0 deletions github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ func testNewRequestAndDoFailure(t *testing.T, methodName string, client *Client,
client.BaseURL.Path = "/api-v3/"
client.rateLimits[0].Reset.Time = time.Now().Add(10 * time.Minute)
resp, err = f()
if bypass := resp.Request.Context().Value(bypassRateLimitCheck); bypass != nil {
return
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned that we are not checking the value of err here... might there be a case where we get an error that will be ignored here?

Copy link
Contributor Author

@sa-spag sa-spag Jun 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This helper explicitly sets the client up to trigger errors, and at this stage a rate limit error. As is, the test would fail if we check for err != nil for methodName == "RateLimits" as the request would result in a HTTP 404, since no handler has been created. We can set one up on TestRateLimits_coverage but I think it makes the test less straightforward. Client.RateLimits rate limit check bypass behavior is already covered by the newly introduced TestRateLimits_overQuota.

}
if want := http.StatusForbidden; resp == nil || resp.Response.StatusCode != want {
if resp != nil {
t.Errorf("rate.Reset.Time > now %v resp = %#v, want StatusCode=%v", methodName, resp.Response, want)
Expand Down