E2E tests against a mockito stub API, testing tiers #14
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/testing-tiers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
tests/e2e.rsruns the realsporahbinary against a mockito stub of the API. It checks the exact output, request paths and exit codes for:cityandcoords--urlvsSPORAH_URL--values-onlyAn ignored test checks the live API. There's a new
CLAUDE.mdwith commands, Blast radius and Testing tiers, and a PR template.On review request, the hand-written TcpListener stub is replaced by mockito 1.7.2, a dev-dependency only. I chose mockito because it has a sync
Server::new(), so the tests stay plain#[test]. Each test declares the exact path and query it expects; any other request gets a 501.Blast radius
Tier: trunk (Cargo.toml / Cargo.lock, for the mockito dev-dependency)
Trunk paths touched: Cargo.toml, Cargo.lock
Testing tier: standard (also: ship on sight, docs)
Gate / rollback: tests and docs only. The release dependency graph is unchanged (
cargo tree -e normal,build --target allis byte-identical). To roll back, revert.Proof
cargo testpasses 9 unit and 8 e2e tests. The liveapi.sporah.eutest passed (run withcargo test -- --ignored).no_content_and_bad_request_mean_no_data.url_flag_beats_env_and_drops_a_trailing_slash.coords_query_the_root_with_lat_and_lon.f2d9dff: CI / ci (2m0s) and CI / audit (12s) are green (run 14).Review
Reviewer:
f2d9dff.Review-Confidence: 100/100 for the mockito delta, with no deductions. The earlier part was leaf and not audited.
Confidence by part
tests/e2e.rs: high. It uses exact-string asserts and was mutation-checked.CLAUDE.mdTesting tiers: medium. The waybar mode and release gates are written down but not yet exercised.🤖 Generated with Claude Code
WIP: E2E tests against a stub API, testing tiersto E2E tests against a stub API, testing tiers@ -0,0 +14,4 @@/// Serves one request with `status` and `body`, and returns the stub's base/// URL plus a receiver for the request target the client sent.fn stub(status: &'static str, body: &'static str) -> (String, mpsc::Receiver<String>) {Is there any crate or library which can more quickly stub or serve as a mock server than hand writing server code?
Replied inline on tests/e2e.rs.
@ -0,0 +11,4 @@/// A stub that answers `GET {path}` with `status` and `body`. Any other/// request gets mockito's 501, and `Mock::assert` fails if `path` was never hit.fn stub(path: &str, status: usize, body: &str) -> (ServerGuard, Mock) {Yes. In
f77b0d7the hand-written stub is replaced with mockito 1.7.2, a dev-dependency only. I picked it over wiremock and httpmock because it has a syncServer::new(), so the tests stay plain#[test]with no tokio runtime.Each test now declares the exact path it expects (
/Berlin,/Rothenburg%20ob%20der%20Tauber,/?lat=52.52&lon=13.4). mockito compares that against the full path and query, and any other request gets a 501, so the old request-target checks still hold. The channel plumbing is gone, and the file is about 40 lines shorter.Checks:
cargo tree -e normal,buildis byte-identical before and after, so the release and musl build don't change.E2E tests against a stub API, testing tiersto E2E tests against a mockito stub API, testing tiers