Repository navigation
Testing
Home · Installation · Compatibility · Tools Reference · Architecture · Providers · Configuration · Reliability · Security · Testing · Troubleshooting · Project Tracker
swift test| Property | Value |
|---|---|
| Tests | 215 (plus 7 opt-in live tests) |
| Runtime | ~6 seconds |
| External network | not required |
| Warnings | none, from a clean build |
End-to-end tests launch the real executable with a scrubbed environment: PATH plus
their own explicit overrides, with every documented provider variable removed.
Without that scrub, an exported TAVILY_API_KEY — exactly what the installation guide
tells a user to set — would make the stub-provider test contact the live vendor and fail.
This was a real defect, so it is now verified rather than assumed:
TAVILY_API_KEY=tvly-fake BRAVE_SEARCH_API_KEY=brave-fake swift testCI runs the whole suite a second time with credentials present for the same reason.
| File | Covers |
|---|---|
CoreUnitTests |
URL canonicalization, configuration parsing, durations, logging |
FusionAndReliabilityTests |
RRF fusion, deduplication, diversity capping, aggregator weighting, circuit breaker, rate limiter, cache |
URLPolicyTests |
SSRF: schemes, loopback/private/metadata literals, DNS resolution, IP classification |
HTMLExtractorTests |
Readable-text extraction, boilerplate removal, scraper parsing, challenge detection |
HTTPClientTests |
Retry, Retry-After, idempotency, size limits, cancellation, Latin-1 fallback |
ProviderContractTests |
Per-adapter contract and failure taxonomy |
SearchOrchestratorTests |
Selection, fan-out, failover, timeouts, caching, domain filtering |
StdioServerTests |
Real MCP handshake, tool schemas, tool calls, stdout purity |
SchemaCompatibilityTests |
Every advertised schema against the strictest client rules |
TransportConfigurationTests |
CLI flag parsing, defaults and rejection of bad arguments |
ErrorReportingTests |
Error attribution, explicit-provider fallback, post-error liveness |
LiveProviderTests |
Opt-in. Real API calls; skipped unless a key is present |
LoopbackServer binds 127.0.0.1 and speaks HTTP/1.1, so retry, Retry-After,
idempotency, size limits and cancellation are verified against real socket behaviour
rather than against a mock that would encode the same assumptions as the client.
Every covered adapter must satisfy the same contract:
| Expectation | Assertion |
|---|---|
| Happy path | Normalized results with valid URLs and ranks |
401 / 403
|
Classified as authentication
|
429 |
Classified as rate_limited, with Retry-After parsed |
5xx |
Classified as transient |
| Malformed body | Clean malformed_response failure, never junk results |
| Cancellation | Stops in-flight work |
| Credentials | Never appear in logs or diagnostics |
Covered: Tavily, Brave, Mojeek, Exa, SearXNG, DuckDuckGo. Gaps are recorded on the Project Tracker.
CircuitBreaker, RateLimiter and SearchCache take an injectable Clock, so cooldown
and expiry tests advance a TestClock instead of sleeping. Timeout tests use short
budgets rather than real waits. Fusion ordering is fully deterministic, so ranking
assertions are stable.
python3 scripts/mcp_smoke.pyA dependency-free client that drives the built binary through a real handshake and asserts that:
-
initializesucceeds and reports the expected server identity; -
tools/listexposes exactly three tools with valid object schemas; -
web_searchwith no provider configured fails as an actionable tool error; - every line written to stdout is valid JSON-RPC;
- diagnostics appear on stderr, never stdout.
It keeps stdin open until all replies have been read, which is what the stdio transport contract requires.
.github/workflows/ci.yml runs on macos-26 (Xcode 26.x, Swift 6.3) for every push and
pull request to main:
swift build --build-testsswift testswift build -c release-
python3 scripts/mcp_smoke.py— stdio handshake and stdout purity -
python3 scripts/mcp_smoke.py --http— starts the HTTP transport, waits for/health, drives a full stateful session over SSE, and checks that requests without a session, without SSE inAccept, and from a cross-origin page are refused -
swift testagain with provider credentials present, proving hermeticity
The toolchain version is asserted before anything else, because a
swift-tools-version: 6.3 manifest cannot even be parsed by an older Swift.
Automation is not ceremony here: it found three defects that local builds had hidden.
-
macos-14ships Swift 5.10, which cannot parse the manifest. -
Package.swiftdeclared a resource bundle for a directory git does not track, so a clean checkout failed to build while local builds passed. - A trailing-
deferwarning that only a from-scratch build surfaced.
swift test --filter LiveProviderTestsThese call real APIs, so they are opt-in and skipped by default. They run only when
TAVILY_API_KEY is present, either in the environment or in a git-ignored config.env
at the package root.
They are written to be frugal with a metered free tier: fast mode, small result
counts, and most assertions made against a single live response. The authentication
path is covered with a deliberately invalid key, which costs no credits. Coverage:
| Test | What it proves | Cost |
|---|---|---|
| Invalid key | A rejected credential is classified as authentication, not transient | free |
| Search | Live results normalize correctly, with scores and sequential ranks | 1 credit |
| Recency | A recency filter returns dated results, so the filter is verifiable | 1 credit |
| Orchestration | Full path with fusion and a cache hit on the repeat query | 1 credit |
| Thorough mode | The advanced-depth mapping reaches the live service | 2 credits |
| Status | A live key reports ready and the payload never contains the key |
free |
This suite exists because it found a defect the stub tests could not: Tavily's
published_date silently decoded to nil, since the DTO maps keys explicitly while the
adapter had been applying .convertFromSnakeCase, which rewrites the key before those
mappings are consulted.
SchemaCompatibilityTests walks every advertised input and output schema, via a real
tools/list over stdio, and fails on any construct a mainstream client rejects: a
missing additionalProperties: false, a property that is not also required, a banned
keyword (format, default, oneOf, allOf, not), an object without properties,
an array without items, a non-object root, or an over-long tool or property name. It
also asserts that defaults are documented in descriptions rather than declared, and that
every required-but-optional property is nullable so a strict client can omit it.
See Compatibility for why each rule exists.
Live provider behaviour is non-deterministic and free tiers are metered. A scheduled live smoke test on CI is still open work on the Project Tracker.
Home · Installation · Tools Reference · Architecture · Providers · Configuration · Reliability · Security · Testing · Troubleshooting · Project Tracker