Skip to content

Testing

Pummelchen edited this page Sep 11, 2026 · 32 revisions

Testing

swift test

179 tests, roughly 6 seconds, and no test contacts the public internet.

Hermeticity

End-to-end tests launch the real executable with a scrubbed environment: PATH plus explicitly set overrides, with every documented provider variable removed. Without this, an exported TAVILY_API_KEY — exactly what the README tells a user to set — would make the stub-provider test contact the live vendor. This was a real defect; it is verified by running the suite under a deliberately dirty environment:

TAVILY_API_KEY=tvly-fake BRAVE_SEARCH_API_KEY=brave-fake swift test

Test groups

File Covers
CoreUnitTests URL canonicalization, configuration parsing, durations, logging
FusionAndReliabilityTests RRF fusion, dedup, diversity capping, aggregator weighting, circuit breaker, rate limiter, cache
URLPolicyTests SSRF: schemes, loopback/private/metadata literals, DNS resolution, classification
HTMLExtractorTests Readable-text extraction, boilerplate removal, scraper parsing, challenge detection
HTTPClientTests Retry, Retry-After, idempotency, size limit, cancellation, Latin-1 fallback
ProviderContractTests Per-adapter contract and failure taxonomy
SearchOrchestratorTests Selection, fan-out, failover, timeouts, caching, filtering
StdioServerTests Real MCP handshake, tool schemas, tool calls, stdout purity
ErrorReportingTests Error attribution, explicit-provider fallback, post-error liveness

Transport tests use a real socket

LoopbackServer binds 127.0.0.1 and speaks HTTP/1.1, so retry, Retry-After, idempotency and cancellation are verified against real socket behaviour rather than a mock that would encode the same assumptions as the client.

Provider contract

Each covered adapter must satisfy the same contract: normalized results, 401/403 → authentication, 429 → rate limited, 5xx → transient, malformed body → clean failure, cancellation respected, and no credential leakage. Tavily, Brave, Mojeek, Exa, SearXNG and DuckDuckGo are covered. See the Project Tracker for the gaps.

Clocks and time

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.

CI

.github/workflows/ci.yml runs on macos-26 (Xcode 26.x, Swift 6.3) for every push and pull request to main:

  1. swift build --build-tests
  2. swift test
  3. swift build -c release
  4. python3 scripts/mcp_smoke.py — an end-to-end handshake against the release binary
  5. swift test again with provider credentials present, which proves the hermeticity claim instead of assuming it

The toolchain version is asserted before anything else, because a swift-tools-version: 6.3 manifest cannot even be parsed by an older Swift.

Not covered here

Live provider behaviour is non-deterministic and free tiers are metered, so live smoke tests belong in a scheduled job rather than the unit suite. That is open work on the tracker.

Clone this wiki locally