- Add GetTestMaxRetries_WithOverride test to verify MAX_RETRIES env var handling
- Add ConfigureTestEnv test to verify all required environment variables are set
- Test coverage includes: valid/invalid env values, all 7 required vars
- All acceptance criteria for bead bf-4lid are now verified
Confirm that test infrastructure in helpers_test.go meets all acceptance criteria:
✅ MockUpstream and CountingMockServer for httptest-based mock upstreams
✅ Request builders (CreateProxyRequest, CreateMessagesRequest, etc.)
✅ Response assertions (AssertStatusCode, AssertJSONBody, etc.)
✅ Test-mode configuration (ConfigureTestEnv, GetTestMaxRetries)
✅ TestHelperFunctions and TestMockUpstreamBasic tests pass
✅ All tests use mock servers, never hit real api.z.ai
The infrastructure was already implemented. This commit validates it works correctly.
Co-Authored-By: Claude <noreply@anthropic.com>
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>