MCPcopy Index your code
hub / github.com/coder/coder / TestGithubRateLimits

Function TestGithubRateLimits

coderd/promoauth/oauth2_test.go:105–230  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

103}
104
105func TestGithubRateLimits(t *testing.T) {
106 t.Parallel()
107
108 now := time.Now()
109 cases := []struct {
110 Name string
111 NoHeaders bool
112 Omit []string
113 ExpectNoMetrics bool
114 Limit int
115 Remaining int
116 Used int
117 Reset time.Time
118
119 at time.Time
120 }{
121 {
122 Name: "NoHeaders",
123 NoHeaders: true,
124 ExpectNoMetrics: true,
125 },
126 {
127 Name: "ZeroHeaders",
128 ExpectNoMetrics: true,
129 },
130 {
131 Name: "OverLimit",
132 Limit: 100,
133 Remaining: 0,
134 Used: 500,
135 Reset: now.Add(time.Hour),
136 at: now,
137 },
138 {
139 Name: "UnderLimit",
140 Limit: 100,
141 Remaining: 0,
142 Used: 500,
143 Reset: now.Add(time.Hour),
144 at: now,
145 },
146 {
147 Name: "Partial",
148 Omit: []string{"x-ratelimit-remaining"},
149 ExpectNoMetrics: true,
150 Limit: 100,
151 Remaining: 0,
152 Used: 500,
153 Reset: now.Add(time.Hour),
154 at: now,
155 },
156 }
157
158 for _, c := range cases {
159 t.Run(c.Name, func(t *testing.T) {
160 t.Parallel()
161
162 reg := prometheus.NewRegistry()

Callers

nothing calls this directly

Calls 15

NewGithubMethod · 0.95
OIDCConfigMethod · 0.95
HTTPClientMethod · 0.95
NewFakeIDPFunction · 0.92
WithMiddlewaresFunction · 0.92
NewFactoryFunction · 0.92
ContextFunction · 0.92
GaugeValueFunction · 0.92
MetricValueFunction · 0.92
RegistryDumpFunction · 0.92
LogMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected