-
Notifications
You must be signed in to change notification settings - Fork 220
Added check for empty charts in chart-repo #604
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
entries: |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -73,6 +73,24 @@ func (h *goodHTTPClient) Do(req *http.Request) (*http.Response, error) { | |||||
return w.Result(), nil | ||||||
} | ||||||
|
||||||
type chartHTTPClient struct{} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we can remove this one and the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like I forgot to remove this one. :) |
||||||
|
||||||
func (h *chartHTTPClient) Do(req *http.Request) (*http.Response, error){ | ||||||
w := httptest.NewRecorder() | ||||||
// Don't accept trailing slashes | ||||||
if strings.HasPrefix(req.URL.Path, "//") { | ||||||
w.WriteHeader(500) | ||||||
} | ||||||
// If subpath repo URL test, check that index.yaml is correctly added to the | ||||||
// subpath | ||||||
if req.URL.Host == "subpath.test" && req.URL.Path != "/subpath/index.yaml" { | ||||||
w.WriteHeader(500) | ||||||
} | ||||||
|
||||||
w.Write(nil) | ||||||
return w.Result(), nil | ||||||
} | ||||||
|
||||||
type authenticatedHTTPClient struct{} | ||||||
|
||||||
func (h *authenticatedHTTPClient) Do(req *http.Request) (*http.Response, error) { | ||||||
|
@@ -570,3 +588,22 @@ h251U/Daz6NiQBM9AxyAw6EHm8XAZBvCuebfzyrT | |||||
t.Error(err) | ||||||
} | ||||||
} | ||||||
|
||||||
var emptyRepoIndexYAMLBytes, _ = ioutil.ReadFile("testdata/empty-repo-index.yaml") | ||||||
var emptyRepoIndexYAML = string(emptyRepoIndexYAMLBytes) | ||||||
|
||||||
type emptyChartRepoHTTPClient struct{} | ||||||
|
||||||
|
||||||
func (h *emptyChartRepoHTTPClient) Do(req *http.Request) (*http.Response, error){ | ||||||
w := httptest.NewRecorder() | ||||||
w.Write([]byte(emptyRepoIndexYAML)) | ||||||
return w.Result(), nil | ||||||
} | ||||||
|
||||||
|
||||||
func Test_emptyChartRepo(t *testing.T) { | ||||||
netClient = &badHTTPClient{} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||
_, err := fetchRepoIndex(repo{URL: "https://my.examplerepo.com"}) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we actually need to call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||
assert.ExistsErr(t, err, "failed request") | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to return the error so that the caller can exit appropriately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done