MCPcopy
hub / github.com/helm/helm / TestHTTPURLLoader_Load

Function TestHTTPURLLoader_Load

pkg/chart/common/util/jsonschema_test.go:253–288  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

251}
252
253func 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

Callers

nothing calls this directly

Calls 10

newHTTPURLLoaderFunction · 0.85
CloseMethod · 0.80
FatalfMethod · 0.80
FatalMethod · 0.80
ContainsMethod · 0.80
RunMethod · 0.65
LoadMethod · 0.65
SetMethod · 0.45
WriteMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…