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

Function testNewRequestAndDoFailureCategory

github/github_test.go:369–403  ·  view source on GitHub ↗

testNewRequestAndDoFailureCategory works Like testNewRequestAndDoFailure, but allows setting the category.

(t *testing.T, methodName string, client *Client, category RateLimitCategory, f func() (*Response, error))

Source from the content-addressed store, hash-verified

367
368// testNewRequestAndDoFailureCategory works Like testNewRequestAndDoFailure, but allows setting the category.
369func testNewRequestAndDoFailureCategory(t *testing.T, methodName string, client *Client, category RateLimitCategory, f func() (*Response, error)) {
370 t.Helper()
371 if methodName == "" {
372 t.Error("testNewRequestAndDoFailure: must supply method methodName")
373 }
374
375 client.baseURL.Path = ""
376 resp, err := f()
377 if resp != nil {
378 t.Errorf("client.BaseURL.Path='' %v resp = %#v, want nil", methodName, resp)
379 }
380 if err == nil {
381 t.Errorf("client.BaseURL.Path='' %v err = nil, want error", methodName)
382 }
383
384 client.baseURL.Path = "/api-v3/"
385 client.rateLimits[category].Reset.Time = time.Now().Add(10 * time.Minute)
386 resp, err = f()
387 if client.disableRateLimitCheck {
388 return
389 }
390 if bypass := resp.Request.Context().Value(BypassRateLimitCheck); bypass != nil {
391 return
392 }
393 if want := http.StatusForbidden; resp == nil || resp.Response.StatusCode != want {
394 if resp != nil {
395 t.Errorf("rate.Reset.Time > now %v resp = %#v, want StatusCode=%v", methodName, resp.Response, want)
396 } else {
397 t.Errorf("rate.Reset.Time > now %v resp = nil, want StatusCode=%v", methodName, want)
398 }
399 }
400 if err == nil {
401 t.Errorf("rate.Reset.Time > now %v err = nil, want error", methodName)
402 }
403}
404
405// Test that all error response types contain the status code.
406func testErrorResponseForStatusCode(t *testing.T, code int) {

Calls 2

AddMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…