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

Function TestHTTPClient_MarshalError

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

Source from the content-addressed store, hash-verified

527}
528
529func TestHTTPClient_MarshalError(t *testing.T) {
530 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
531 w.WriteHeader(http.StatusOK)
532 }))
533 defer server.Close()
534
535 client := NewHTTPClient(server.Client(), server.URL, testutils.NewTestLogger())
536
537 // Use data that cannot be marshaled to JSON (channel)
538 invalidData := map[string]interface{}{
539 "channel": make(chan int),
540 }
541
542 var result map[string]interface{}
543 err := client.Post(context.Background(), "/test", invalidData, &result)
544
545 require.Error(t, err)
546 assert.Contains(t, err.Error(), "failed to marshal request data")
547}
548
549func TestHTTPClient_NilResult(t *testing.T) {
550 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 6

PostMethod · 0.95
NewTestLoggerFunction · 0.92
NewHTTPClientFunction · 0.85
ClientMethod · 0.80
CloseMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected