TestReadFileErrorMessages tests specific error scenarios and their messages
(t *testing.T)
| 249 | |
| 250 | // TestReadFileErrorMessages tests specific error scenarios and their messages |
| 251 | func 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 |
| 287 | func TestReadFileOriginal(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…