MCPcopy Create free account
hub / github.com/cronitorio/cronitor-cli / TestAPIClient_NetworkError

Function TestAPIClient_NetworkError

lib/api_client_test.go:399–413  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

397}
398
399func TestAPIClient_NetworkError(t *testing.T) {
400 // Create a server and immediately close it to simulate connection refused
401 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
402 serverURL := server.URL
403 server.Close()
404
405 client := newTestClient(serverURL)
406 _, err := client.GET("/monitors", nil)
407 if err == nil {
408 t.Error("expected network error, got nil")
409 }
410 if !strings.Contains(err.Error(), "request failed") {
411 t.Errorf("expected 'request failed' in error, got %q", err.Error())
412 }
413}
414
415func TestAPIClient_MalformedJSON(t *testing.T) {
416 mock := testutil.NewMockAPI()

Callers

nothing calls this directly

Calls 4

newTestClientFunction · 0.85
CloseMethod · 0.80
GETMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected