Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions internal/config/validation_schema_fetch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,13 @@ func TestFetchAndFixSchema_HTTPError(t *testing.T) {

// TestFetchAndFixSchema_NetworkError tests handling of network failures
func TestFetchAndFixSchema_NetworkError(t *testing.T) {
// Use an invalid URL that will cause a network error
invalidURL := "http://invalid-host-that-does-not-exist-12345.com/schema.json"
// Start a server and immediately close it so connections are refused,
// guaranteeing a network error without relying on external DNS resolution.
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
closedURL := server.URL + "/schema.json"
server.Close()

result, err := fetchAndFixSchema(invalidURL)
result, err := fetchAndFixSchema(closedURL)

assert.Error(t, err)
assert.Nil(t, result)
Expand Down
Loading