Skip to main content

Module mock_engine

Module mock_engine 

Source
Expand description

Axum-based mock of the engine’s FastAPI surface.

Mirrors the JSON shapes emitted by engine/zero/server.py for the endpoints the CLI actually calls. Missing endpoints return 404 so tests fail loud when a new call is added without a mock.

Usage in tests:

let mock = MockEngine::spawn().await?;
let base = mock.base_url();
// … construct an HttpClient against `base` and exercise it …
mock.shutdown().await;

Structs§

AppState
Shared state for the mock axum app.
CapturedPost
A snapshot of one POST the mock captured — headers (lowercased names, string values) plus a parsed-JSON body. Structured so a failing assertion in a test prints the full payload rather than a byte vector the human has to decode by hand.
MockEngine
A running mock. Holds the listening address and a shutdown handle; automatically aborts on drop as a safety net, but prefer explicit .shutdown() so the port is reclaimable immediately.
Overrides
Overrides the test can inject to simulate engine states.