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

Function TestRateLimits

github/rate_limit_test.go:39–203  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

37}
38
39func TestRateLimits(t *testing.T) {
40 t.Parallel()
41 client, mux, _ := setup(t)
42
43 mux.HandleFunc("/rate_limit", func(w http.ResponseWriter, r *http.Request) {
44 testMethod(t, r, "GET")
45 fmt.Fprint(w, `{"resources":{
46 "core": {"limit":2,"remaining":1,"used":1,"reset":1372700873},
47 "search": {"limit":3,"remaining":2,"used":1,"reset":1372700874},
48 "graphql": {"limit":4,"remaining":3,"used":1,"reset":1372700875},
49 "integration_manifest": {"limit":5,"remaining":4,"used":1,"reset":1372700876},
50 "source_import": {"limit":6,"remaining":5,"used":1,"reset":1372700877},
51 "code_scanning_upload": {"limit":7,"remaining":6,"used":1,"reset":1372700878},
52 "actions_runner_registration": {"limit":8,"remaining":7,"used":1,"reset":1372700879},
53 "scim": {"limit":9,"remaining":8,"used":1,"reset":1372700880},
54 "dependency_snapshots": {"limit":10,"remaining":9,"used":1,"reset":1372700881},
55 "code_search": {"limit":11,"remaining":10,"used":1,"reset":1372700882},
56 "audit_log": {"limit": 12,"remaining":11,"used":1,"reset":1372700883},
57 "dependency_sbom": {"limit": 100,"remaining":100,"used":0,"reset":1372700884}
58 }}`)
59 })
60
61 ctx := t.Context()
62 rate, _, err := client.RateLimit.Get(ctx)
63 if err != nil {
64 t.Errorf("RateLimits returned error: %v", err)
65 }
66
67 want := &RateLimits{
68 Core: &Rate{
69 Limit: 2,
70 Remaining: 1,
71 Used: 1,
72 Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 53, 0, time.UTC).Local()},
73 },
74 Search: &Rate{
75 Limit: 3,
76 Remaining: 2,
77 Used: 1,
78 Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 54, 0, time.UTC).Local()},
79 },
80 GraphQL: &Rate{
81 Limit: 4,
82 Remaining: 3,
83 Used: 1,
84 Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 55, 0, time.UTC).Local()},
85 },
86 IntegrationManifest: &Rate{
87 Limit: 5,
88 Remaining: 4,
89 Used: 1,
90 Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 56, 0, time.UTC).Local()},
91 },
92 SourceImport: &Rate{
93 Limit: 6,
94 Remaining: 5,
95 Used: 1,
96 Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 57, 0, time.UTC).Local()},

Callers

nothing calls this directly

Calls 4

testMethodFunction · 0.85
EqualMethod · 0.80
setupFunction · 0.70
GetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…