chore: print the url of failed download (#96)

This commit is contained in:
Carlos Sanchez 2022-02-22 23:59:39 +01:00 committed by GitHub
parent c5f7348af8
commit 932b35d71f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View file

@ -80,7 +80,7 @@ func (r SchemaRegistry) DownloadSchema(resourceKind, resourceAPIVersion, k8sVers
}
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("error while downloading schema - received HTTP status %d", resp.StatusCode)
return nil, fmt.Errorf("error while downloading schema at %s - received HTTP status %d", url, resp.StatusCode)
}
body, err := ioutil.ReadAll(resp.Body)

View file

@ -61,6 +61,22 @@ func TestDownloadSchema(t *testing.T) {
nil,
fmt.Errorf("no schema found"),
},
{
"getting 503",
newMockHTTPGetter(func(url string) (resp *http.Response, err error) {
return &http.Response{
StatusCode: http.StatusServiceUnavailable,
Body: ioutil.NopCloser(strings.NewReader("http response mock body")),
}, nil
}),
"http://kubernetesjson.dev",
true,
"Deployment",
"v1",
"1.18.0",
nil,
fmt.Errorf("error while downloading schema at http://kubernetesjson.dev - received HTTP status 503"),
},
{
"200",
newMockHTTPGetter(func(url string) (resp *http.Response, err error) {