zai-proxy/notes
jedarden 2cdef80126 test(bf-3zp): add mock upstream server test infrastructure
Add comprehensive test infrastructure for retry/response-validation tests
in proxy package. Provides httptest-based mock upstream server, test
helpers for request/response handling, and test-mode configuration for
fast test execution.

New file: proxy/helpers_test.go
- MockUpstream: Configurable HTTP server simulating Z.AI upstream
- Test scenarios: 429 with/without Retry-After, empty/invalid JSON body,
  empty streaming, 422/500/404 responses, network errors, success
- Request builders: CreateProxyRequest, CreateMessagesRequest,
  CreateStreaming/NonStreaming* helpers
- Response assertions: AssertStatusCode, AssertJSONBody, AssertResponseField,
  AssertEmptyBody, AssertHeader, AssertContentType
- Proxy handler factory: CreateTestProxyHandler for configured test handlers
- Test execution helpers: ExecuteProxyRequest, ExecuteMessagesRequest
- Test-mode config: ConfigureTestEnv, GetTestMaxRetries (defaults to 1 for fast tests)
- Backoff delay helpers: CalculateBackoffDelay, CalculateTotalMaxDelay

Acceptance criteria met:
 New test helpers with httptest servers
 Helper functions for requests and assertions
 Test-mode env var for fast tests (MAX_RETRIES=1 default)
 go test ./proxy/ -run TestHelper passes

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-02 12:45:10 -04:00
..
bf-3gx.md test(ratelimiter): make AdaptiveRateLimiter testable via window duration injection 2026-07-02 10:55:06 -04:00
bf-3j1.md test(ratelimiter): make AdaptiveRateLimiter testable via window duration injection 2026-07-02 10:55:06 -04:00
bf-3zp.md test(bf-3zp): add mock upstream server test infrastructure 2026-07-02 12:45:10 -04:00
bf-4a2.md docs(plan): mark migration checklist complete 2026-06-21 10:38:46 -04:00
bf-4co.md docs(notes): document bead bf-4co completion - README fixes already done in a106abd 2026-07-02 07:59:17 -04:00
bf-47d.md docs(bf-47d): document that TestAdaptiveRateLimiter_BasicState already exists 2026-07-02 12:30:34 -04:00