MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / TestHTTPClient_InvalidJSON

Function TestHTTPClient_InvalidJSON

pkg/api/http_test.go:351–365  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

349}
350
351func TestHTTPClient_InvalidJSON(t *testing.T) {
352 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
353 w.Header().Set("Content-Type", "application/json")
354 _, _ = w.Write([]byte("invalid json"))
355 }))
356 defer server.Close()
357
358 client := NewHTTPClient(server.Client(), server.URL, testutils.NewTestLogger())
359
360 var result map[string]interface{}
361 err := client.Get(context.Background(), "/test", &result)
362
363 require.Error(t, err)
364 assert.Contains(t, err.Error(), "failed to parse response JSON")
365}
366
367func TestHTTPClient_NetworkError(t *testing.T) {
368 // Use invalid URL to simulate network error

Callers

nothing calls this directly

Calls 8

GetMethod · 0.95
NewTestLoggerFunction · 0.92
NewHTTPClientFunction · 0.85
HeaderMethod · 0.80
ClientMethod · 0.80
SetMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected