pub fn render_common_module() -> StringExpand description
Generate the tests/common.rs module for Rust e2e tests.
The module spawns the standalone mock-server binary once per test process
and exposes it via mock_server_url() which reads the MOCK_SERVER_URL env var.
This allows tests that use mock_url arguments to access the server dynamically
without panicking on unset env vars.
The module:
- Spawns
target/release/mock-serverwith the fixtures directory as an argument - Reads stdout lines looking for
MOCK_SERVER_URL=http://...andMOCK_SERVERS={...} - Sets environment variables:
MOCK_SERVER_URLandMOCK_SERVER_<FIXTURE_ID>for each entry - Drains remaining stdout in a background thread to prevent blocking
- Uses
OnceLockto ensure the server is spawned exactly once