Testing exists because shunt’s correctness is mostly protocol preservation. The dangerous failures are subtle: a beta header split incorrectly, an SSE stream buffered until the end, a tool call ID lost during translation, or an upstream error hidden behind a generic gateway error. The repository uses colocated unit tests plus Wiremock integration tests to lock those behaviors down tests/passthrough.rs:72-247 tests/responses_translate.rs:25-287.
graph TB
subgraph Unit[Colocated unit tests]
Config[config.rs tests]
Routing[routing.rs tests]
Auth[auth tests]
Adapter[adapter tests]
end
subgraph Integration[tests]
Pass[passthrough.rs]
Translate[responses_translate.rs]
end
subgraph CI[GitHub Actions]
Fmt[cargo fmt]
Clippy[cargo clippy -D warnings]
CargoTest[cargo test]
end
Unit --> CargoTest
Integration --> CargoTest
Fmt --> Clippy --> CargoTest
classDef dark fill:#2d333b,stroke:#6d5dfc,color:#e6edf3;
class Config,Routing,Auth,Adapter,Pass,Translate,Fmt,Clippy,CargoTest dark;
style Unit fill:#161b22,stroke:#30363d,color:#e6edf3;
style Integration fill:#161b22,stroke:#30363d,color:#e6edf3;
style CI fill:#161b22,stroke:#30363d,color:#e6edf3;
linkStyle default stroke:#8b949e;
sequenceDiagram
autonumber
participant Test as Wiremock test
participant Gateway as shunt gateway
participant Mock as Mock upstream
Test->>Mock: mount expected request matchers
Test->>Gateway: POST /v1/messages or count_tokens
Gateway->>Mock: forwarded request
Mock-->>Gateway: configured status/body/stream
Gateway-->>Test: response
Test->>Mock: verify expected calls
flowchart LR
Input[Anthropic fixture] --> Translate[translate_request]
Translate --> Assertions[JSON assertions]
SSE[Responses SSE fixture] --> Parse[parse_sse_events]
Parse --> Machine[AnthropicSseMachine]
Machine --> EventAssertions[Event name and payload assertions]
Error[OpenAI/Codex error shapes] --> Map[map_error_value]
Map --> ErrorAssertions[Anthropic error assertions]
classDef dark fill:#2d333b,stroke:#6d5dfc,color:#e6edf3;
class Input,Translate,Assertions,SSE,Parse,Machine,EventAssertions,Error,Map,ErrorAssertions dark;
linkStyle default stroke:#8b949e;
stateDiagram-v2
[*] --> Checkout
Checkout --> RustToolchain
RustToolchain --> CacheCargo
CacheCargo --> FormatCheck
FormatCheck --> Clippy
Clippy --> Tests
Tests --> Success
FormatCheck --> Failed: formatting differs
Clippy --> Failed: warning or lint
Tests --> Failed: test failure
Success --> [*]