MCPcopy Index your code
hub / github.com/google/go-github / TestCheckResponse_AbuseRateLimit

Function TestCheckResponse_AbuseRateLimit

github/github_test.go:3326–3348  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3324}
3325
3326func 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.

Callers

nothing calls this directly

Calls 3

CheckResponseFunction · 0.85
ErrorMethod · 0.45
IsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…