You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ifghErr, ok:= userErr.(*github.ErrorResponse); ok {
150
150
fmt.Println(ghErr.Message) // == "github went belly up or something"
151
151
}
152
152
}
153
153
154
154
```
155
155
156
-
## Mocking with pagination
156
+
###Mocking with pagination
157
157
158
158
```golang
159
159
mockedHTTPClient:=NewMockedHTTPClient(
@@ -214,7 +214,7 @@ for {
214
214
// len(allRepos) == 4
215
215
```
216
216
217
-
## Mocking for Github Enterprise
217
+
###Mocking for GitHub Enterprise
218
218
219
219
Github Enterprise uses a different prefix for its endpoints. In order to use the correct endpoints, please use the different set of `*Enterprise` options:
// The rate limiter will allow 10 requests per second, and a burst size of 1.
258
+
// These two options together mean that the rate of requests will be strictly enforced, so if any two requests are
259
+
// made less than 1/10th of a second apart, the latter will be refused and come back with a rate limit error.
260
+
mock.WithRateLimit(10, 1),
261
+
)
262
+
```
263
+
264
+
## Why
244
265
245
-
Some conversations got started on [go-github#1800](https://github.com/google/go-github/issues/1800) since `go-github` didn't provide an interface that could be easily reimplemented for unittests. After lots of conversations from the folks from [go-github](https://github.com/google/go-github) and quite a few PR ideas later, this style of testing was deemed not suitable to be part of the core SDK as it's not a feature of the API itself. Nonetheless, the ability of writing unittests for code that uses the `go-github` package is critical.
266
+
Some conversations got started on [go-github#1800](https://github.com/google/go-github/issues/1800) since `go-github` didn't provide an interface that could be easily reimplemented for unittests. After lots of conversations from the folks from [go-github](https://github.com/google/go-github) and quite a few PR ideas later, this style of testing was deemed not suitable to be part of the core SDK as it's not a feature of the API itself. Nonetheless, the ability of writing unittests for code that uses the `go-github` package is critical.
246
267
247
268
A reuseable, and not overly verbose, way of writing the tests was reached after some more interactions (months down the line) and here we are.
248
269
249
-
# Thanks
270
+
##Thanks
250
271
251
272
Thanks for all ideas and feedback from the folks in [go-github](https://github.com/google/go-github/).
252
273
253
-
# License
274
+
##License
254
275
255
276
This library is distributed under the MIT License found in LICENSE.
0 commit comments