(t *testing.T)
| 376 | } |
| 377 | |
| 378 | func TestHTTPClient_ContextCancellation(t *testing.T) { |
| 379 | // Create server that delays response to test context cancellation |
| 380 | server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 381 | // Wait longer than the context timeout |
| 382 | time.Sleep(200 * time.Millisecond) |
| 383 | w.WriteHeader(http.StatusOK) |
| 384 | })) |
| 385 | defer server.Close() |
| 386 | |
| 387 | client := NewHTTPClient(server.Client(), server.URL, testutils.NewTestLogger()) |
| 388 | |
| 389 | // Create context with short timeout |
| 390 | ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond) |
| 391 | defer cancel() |
| 392 | |
| 393 | var result map[string]interface{} |
| 394 | err := client.Get(ctx, "/test", &result) |
| 395 | |
| 396 | require.Error(t, err) |
| 397 | assert.Contains(t, err.Error(), "context deadline exceeded") |
| 398 | } |
| 399 | |
| 400 | func TestHTTPClient_GetWithRetry_Success(t *testing.T) { |
| 401 | attemptCount := 0 |
nothing calls this directly
no test coverage detected