(t *testing.T)
| 3324 | } |
| 3325 | |
| 3326 | func TestCheckResponse_AbuseRateLimit(t *testing.T) { |
| 3327 | t.Parallel() |
| 3328 | res := &http.Response{ |
| 3329 | Request: &http.Request{}, |
| 3330 | StatusCode: http.StatusForbidden, |
| 3331 | Body: io.NopCloser(strings.NewReader(`{"message":"m", |
| 3332 | "documentation_url": "docs.github.com/en/rest/overview/resources-in-the-rest-api#abuse-rate-limits"}`)), |
| 3333 | } |
| 3334 | var err *AbuseRateLimitError |
| 3335 | errors.As(CheckResponse(res), &err) |
| 3336 | |
| 3337 | if err == nil { |
| 3338 | t.Error("Expected error response.") |
| 3339 | } |
| 3340 | |
| 3341 | want := &AbuseRateLimitError{ |
| 3342 | Response: res, |
| 3343 | Message: "m", |
| 3344 | } |
| 3345 | if !errors.Is(err, want) { |
| 3346 | t.Errorf("Error = %#v, want %#v", err, want) |
| 3347 | } |
| 3348 | } |
| 3349 | |
| 3350 | // TestCheckResponse_RateLimit_TooManyRequests tests that HTTP 429 with |
| 3351 | // X-RateLimit-Remaining: 0 is correctly detected as RateLimitError. |
nothing calls this directly
no test coverage detected
searching dependent graphs…