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

Function TestCheckResponse_RateLimit

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

Source from the content-addressed store, hash-verified

3292}
3293
3294func TestCheckResponse_RateLimit(t *testing.T) {
3295 t.Parallel()
3296 res := &http.Response{
3297 Request: &http.Request{},
3298 StatusCode: http.StatusForbidden,
3299 Header: http.Header{},
3300 Body: io.NopCloser(strings.NewReader(`{"message":"m",
3301 "documentation_url": "url"}`)),
3302 }
3303 res.Header.Set(HeaderRateLimit, "60")
3304 res.Header.Set(HeaderRateRemaining, "0")
3305 res.Header.Set(HeaderRateUsed, "1")
3306 res.Header.Set(HeaderRateReset, "243424")
3307 res.Header.Set(HeaderRateResource, "core")
3308
3309 var err *RateLimitError
3310 errors.As(CheckResponse(res), &err)
3311
3312 if err == nil {
3313 t.Error("Expected error response.")
3314 }
3315
3316 want := &RateLimitError{
3317 Rate: parseRate(res),
3318 Response: res,
3319 Message: "m",
3320 }
3321 if !errors.Is(err, want) {
3322 t.Errorf("Error = %#v, want %#v", err, want)
3323 }
3324}
3325
3326func TestCheckResponse_AbuseRateLimit(t *testing.T) {
3327 t.Parallel()

Callers

nothing calls this directly

Calls 4

CheckResponseFunction · 0.85
parseRateFunction · 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…