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