(t *testing.T)
| 371 | } |
| 372 | |
| 373 | func TestAPIClient_500_ServerError(t *testing.T) { |
| 374 | mock := testutil.NewMockAPI() |
| 375 | defer mock.Close() |
| 376 | |
| 377 | errBody := testutil.LoadFixture("error_responses/500.json") |
| 378 | mock.On("GET", "/monitors", 500, errBody) |
| 379 | |
| 380 | client := newTestClient(mock.Server.URL) |
| 381 | resp, err := client.GET("/monitors", nil) |
| 382 | if err != nil { |
| 383 | t.Fatalf("unexpected error: %v", err) |
| 384 | } |
| 385 | |
| 386 | if resp.StatusCode != 500 { |
| 387 | t.Errorf("expected 500, got %d", resp.StatusCode) |
| 388 | } |
| 389 | if resp.IsSuccess() { |
| 390 | t.Error("expected IsSuccess() to be false") |
| 391 | } |
| 392 | |
| 393 | parsed := resp.ParseError() |
| 394 | if !strings.Contains(parsed, "Internal server error") { |
| 395 | t.Errorf("expected 'Internal server error', got %q", parsed) |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | func TestAPIClient_NetworkError(t *testing.T) { |
| 400 | // Create a server and immediately close it to simulate connection refused |
nothing calls this directly
no test coverage detected