mustNewGHClient creates a new GitHub client for testing. If httpClient is nil, a client with no options is created. The test fails immediately if client creation fails.
(t *testing.T, httpClient *http.Client)
| 195 | // If httpClient is nil, a client with no options is created. |
| 196 | // The test fails immediately if client creation fails. |
| 197 | func mustNewGHClient(t *testing.T, httpClient *http.Client) *gogithub.Client { |
| 198 | t.Helper() |
| 199 | var client *gogithub.Client |
| 200 | var err error |
| 201 | if httpClient == nil { |
| 202 | client, err = gogithub.NewClient() |
| 203 | } else { |
| 204 | client, err = gogithub.NewClient(gogithub.WithHTTPClient(httpClient)) |
| 205 | } |
| 206 | require.NoError(t, err) |
| 207 | return client |
| 208 | } |
| 209 | |
| 210 | // expect is a helper function to create a partial mock that expects various |
| 211 | // request behaviors, such as path, query parameters, and request body. |
no outgoing calls
no test coverage detected