(ctx context.Context, httpClient *http.Client, host string, p string)
| 252 | } |
| 253 | |
| 254 | func fetchReleasePath(ctx context.Context, httpClient *http.Client, host string, p string) (*Release, error) { |
| 255 | req, err := http.NewRequestWithContext(ctx, "GET", ghinstance.RESTPrefix(host)+p, nil) |
| 256 | if err != nil { |
| 257 | return nil, err |
| 258 | } |
| 259 | |
| 260 | resp, err := httpClient.Do(req) |
| 261 | if err != nil { |
| 262 | return nil, err |
| 263 | } |
| 264 | defer resp.Body.Close() |
| 265 | |
| 266 | if resp.StatusCode == http.StatusNotFound { |
| 267 | _, _ = io.Copy(io.Discard, resp.Body) |
| 268 | return nil, ErrReleaseNotFound |
| 269 | } else if resp.StatusCode > 299 { |
| 270 | return nil, api.HandleHTTPError(resp) |
| 271 | } |
| 272 | |
| 273 | var release Release |
| 274 | if err := json.NewDecoder(resp.Body).Decode(&release); err != nil { |
| 275 | return nil, err |
| 276 | } |
| 277 | |
| 278 | return &release, nil |
| 279 | } |
| 280 | |
| 281 | func StubFetchRelease(t *testing.T, reg *httpmock.Registry, owner, repoName, tagName, responseBody string) { |
| 282 | path := "repos/OWNER/REPO/releases/tags/v1.2.3" |
no test coverage detected