Skip to content

test: add more messages api cases#98

Merged
bzp2010 merged 1 commit into
mainfrom
bzp/test-messages-more-cases
May 9, 2026
Merged

test: add more messages api cases#98
bzp2010 merged 1 commit into
mainfrom
bzp/test-messages-more-cases

Conversation

@bzp2010
Copy link
Copy Markdown
Collaborator

@bzp2010 bzp2010 commented May 9, 2026

Summary by CodeRabbit

  • Tests
    • Significantly expanded test coverage for the message proxying service with comprehensive end-to-end scenarios covering event ordering, error handling, streaming behavior, and format conversion flows.
    • Added extensive validation tests for various content type conversions, format compatibility, and edge case scenarios to enhance service reliability and robustness.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

📝 Walkthrough

Walkthrough

This PR extends the proxy message test suite with 577 new lines of comprehensive end-to-end test coverage for Anthropic /v1/messages proxying. Tests validate SSE streaming semantics, error event emission, tool call and image block mapping, request transformation, control forwarding, and input validation for unsupported cache control.

Changes

Anthropic Message Proxy Tests

Layer / File(s) Summary
Test Infrastructure
tests/proxy/messages.test.ts
Added buildOpenAiToolCallStreamEvents import for stream event generation.
Streaming Response Tests
tests/proxy/messages.test.ts
Added tests for exact SSE event ordering with terminal message_delta stop reason/usage semantics; error event emission on mid-stream malformed tool-call chunks; and text/tool event lifecycle ordering in mixed-content streams.
Non-Streaming Response Mapping
tests/proxy/messages.test.ts
Added test mapping upstream tool-call responses into Anthropic tool_use content blocks with stop reason and structured tool input.
Request Bridging & Transformations
tests/proxy/messages.test.ts
Added tests for Anthropic tool_use/tool_result to upstream tool call conversion; image blocks to upstream image_url parts; tool_choice mapping (any → required mode; named → function selection); system block metadata and generation control (top_k, stop_sequences) forwarding; and rejection of unsupported cache_control at top-level and content block layers.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • api7/aisix#39: Implements the Anthropic /v1/messages proxy handler and routing logic directly validated by these new end-to-end tests.
🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
E2e Test Quality Review ✅ Passed True E2E tests with real app and etcd. 20 tests covering streaming, tool-calling, bridging, auth/errors. Proper isolation, clean assertions, comprehensive scenarios.
Security Check ✅ Passed Test file with no security vulnerabilities. All credentials are test placeholders. No logging, database operations, or sensitive data exposure. Proper authorization test coverage present.
Title check ✅ Passed The title 'test: add more messages api cases' is directly related to the changeset, which adds 577 lines of new test coverage for the messages API proxy.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bzp/test-messages-more-cases

Comment @coderabbitai help to get the list of available commands and usage tips.

@bzp2010 bzp2010 changed the title test: add more messages cases test: add more messages api cases May 9, 2026
@bzp2010 bzp2010 merged commit cc43c0c into main May 9, 2026
3 checks passed
@bzp2010 bzp2010 deleted the bzp/test-messages-more-cases branch May 9, 2026 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant