(t *testing.T)
| 251 | } |
| 252 | |
| 253 | func TestHTTPURLLoader_Load(t *testing.T) { |
| 254 | // Test successful JSON schema loading |
| 255 | t.Run("successful load", func(t *testing.T) { |
| 256 | server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 257 | w.Header().Set("Content-Type", "application/json") |
| 258 | w.WriteHeader(http.StatusOK) |
| 259 | w.Write([]byte(`{"type": "object", "properties": {"name": {"type": "string"}}}`)) |
| 260 | })) |
| 261 | defer server.Close() |
| 262 | |
| 263 | loader := newHTTPURLLoader() |
| 264 | result, err := loader.Load(server.URL) |
| 265 | if err != nil { |
| 266 | t.Fatalf("Expected no error, got: %v", err) |
| 267 | } |
| 268 | if result == nil { |
| 269 | t.Fatal("Expected result to be non-nil") |
| 270 | } |
| 271 | }) |
| 272 | |
| 273 | t.Run("HTTP error status", func(t *testing.T) { |
| 274 | server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 275 | w.WriteHeader(http.StatusNotFound) |
| 276 | })) |
| 277 | defer server.Close() |
| 278 | |
| 279 | loader := newHTTPURLLoader() |
| 280 | _, err := loader.Load(server.URL) |
| 281 | if err == nil { |
| 282 | t.Fatal("Expected error for HTTP 404") |
| 283 | } |
| 284 | if !strings.Contains(err.Error(), "404") { |
| 285 | t.Errorf("Expected error message to contain '404', got: %v", err) |
| 286 | } |
| 287 | }) |
| 288 | } |
| 289 | |
| 290 | // Test that an unresolved URN $ref is soft-ignored and validation succeeds. |
| 291 | // it mimics the behavior of Helm 3.18.4 |
nothing calls this directly
no test coverage detected
searching dependent graphs…