MCPcopy
hub / github.com/helm/helm / TestUpdateChartsFailWithError

Function TestUpdateChartsFailWithError

pkg/cmd/repo_update_test.go:164–212  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

162}
163
164func TestUpdateChartsFailWithError(t *testing.T) {
165 defer resetEnv()()
166 ensure.HelmHome(t)
167
168 ts := repotest.NewTempServer(
169 t,
170 repotest.WithChartSourceGlob("testdata/testserver/*.*"),
171 )
172 defer ts.Stop()
173
174 var invalidURL = ts.URL() + "55"
175 r1, err := repo.NewChartRepository(&repo.Entry{
176 Name: "charts",
177 URL: invalidURL,
178 }, getter.All(settings))
179 if err != nil {
180 t.Error(err)
181 }
182 r2, err := repo.NewChartRepository(&repo.Entry{
183 Name: "charts",
184 URL: invalidURL,
185 }, getter.All(settings))
186 if err != nil {
187 t.Error(err)
188 }
189
190 b := bytes.NewBuffer(nil)
191 err = updateCharts([]*repo.ChartRepository{r1, r2}, b)
192 if err == nil {
193 t.Error("Repo update should return error because update of repository fails and 'fail-on-repo-update-fail' flag set")
194 return
195 }
196 var expectedErr = "failed to update the following repositories"
197 var receivedErr = err.Error()
198 if !strings.Contains(receivedErr, expectedErr) {
199 t.Errorf("Expected error (%s) but got (%s) instead", expectedErr, receivedErr)
200 }
201 if !strings.Contains(receivedErr, invalidURL) {
202 t.Errorf("Expected invalid URL (%s) in error message but got (%s) instead", invalidURL, receivedErr)
203 }
204
205 got := b.String()
206 if !strings.Contains(got, "Unable to get an update") {
207 t.Errorf("Repo should have failed update but instead got: %q", got)
208 }
209 if strings.Contains(got, "Update Complete.") {
210 t.Error("Update was not successful and should return error message because 'fail-on-repo-update-fail' flag set")
211 }
212}

Callers

nothing calls this directly

Calls 11

HelmHomeFunction · 0.92
NewTempServerFunction · 0.92
WithChartSourceGlobFunction · 0.92
AllFunction · 0.92
updateChartsFunction · 0.85
StopMethod · 0.80
URLMethod · 0.80
ContainsMethod · 0.80
resetEnvFunction · 0.70
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…