Commit graph

3 commits

Author SHA1 Message Date
jedarden
1b597190b1 test(bf-4lid): add comprehensive test environment config helper tests
- 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
2026-07-02 17:39:34 -04:00
jedarden
a9a8324c31 test(bf-3zp): validate test infrastructure for mock upstream server
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>
2026-07-02 13:26:28 -04:00
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