MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / TestCall_Fail_DecodeResponse

Function TestCall_Fail_DecodeResponse

internal/request/request_test.go:74–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

72}
73
74func TestCall_Fail_DecodeResponse(t *testing.T) {
75 // Mock server to return a malformed response
76 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
77 w.WriteHeader(http.StatusOK)
78 _, err := w.Write([]byte(`{malformed json response`)) // Invalid JSON
79 assert.NoError(t, err)
80 }))
81 defer server.Close()
82
83 req, err := http.NewRequest("GET", server.URL, nil)
84 assert.NoError(t, err)
85
86 var response map[string]string
87 resp, err := request.Call(req, &response)
88 assert.Error(t, err)
89 assert.Equal(t, http.StatusOK, resp.StatusCode)
90}
91
92func TestCall_Fail_DoRequest(t *testing.T) {
93 // Create a request with an invalid URL

Callers

nothing calls this directly

Calls 3

CallFunction · 0.92
CloseMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected