ContributingTesting
Unit and API tests
cargo test runs each test that needs no Docker. The run takes seconds.
cargo test --workspaceAn API test sends a request to the real router.
1 / 3
What runs
| Tests | Where | What they do |
|---|---|---|
| Unit tests | Next to the code, in each crate | |
| API tests | crates/ferry-api/tests/ | The real router on a store in memory, with a MockEngine in the place of the engine. They cover each route, authentication, errors, blueprints, webhooks, the change feed and concurrency. |
| Builder tests | crates/ferry-build/tests/build_pipeline.rs | Fetch, detect, generate, build and cleanup. A fake docker CLI records what it receives. |
| Proxy and TLS tests | The proxy against local upstreams. The certificate manager through real TLS handshakes, with no network. | |
| The OpenAPI check | crates/ferry-api/tests/openapi.rs | One list of routes must agree with the router, the OpenAPI document and src/lib.rs. A new route with no documentation fails here. |
A mock does no real work. Thus these tests run without Docker.
Run fewer tests
cargo test -p ferry-api # one crate
cargo test -p ferry-api --test blueprints # one test file
cargo test -p ferry-core env:: # tests whose name matches