MCPcopy Index your code
hub / github.com/helm/helm / TestReadFileErrorMessages

Function TestReadFileErrorMessages

pkg/cli/values/options_test.go:251–284  ·  view source on GitHub ↗

TestReadFileErrorMessages tests specific error scenarios and their messages

(t *testing.T)

Source from the content-addressed store, hash-verified

249
250// TestReadFileErrorMessages tests specific error scenarios and their messages
251func TestReadFileErrorMessages(t *testing.T) {
252 tests := []struct {
253 name string
254 filePath string
255 providers getter.Providers
256 wantErr string
257 }{
258 {
259 name: "URL parse error",
260 filePath: "://invalid",
261 providers: getter.Providers{},
262 wantErr: "missing protocol scheme",
263 },
264 {
265 name: "getter error with message",
266 filePath: "http://example.com/file",
267 providers: getter.Providers{mockProvider([]string{"http"}, nil, errors.New("connection refused"))},
268 wantErr: "connection refused",
269 },
270 }
271
272 for _, tt := range tests {
273 t.Run(tt.name, func(t *testing.T) {
274 _, err := readFile(tt.filePath, tt.providers)
275 if err == nil {
276 t.Errorf("readFile() expected error containing %q, got nil", tt.wantErr)
277 return
278 }
279 if !strings.Contains(err.Error(), tt.wantErr) {
280 t.Errorf("readFile() error = %v, want error containing %q", err, tt.wantErr)
281 }
282 })
283 }
284}
285
286// Original test case - keeping for backward compatibility
287func TestReadFileOriginal(t *testing.T) {

Callers

nothing calls this directly

Calls 5

mockProviderFunction · 0.85
readFileFunction · 0.85
ContainsMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…