Skip to main content

render_mock_server_setup

Function render_mock_server_setup 

Source
pub fn render_mock_server_setup(
    out: &mut String,
    fixture: &Fixture,
    e2e_config: &E2eConfig,
    var_name: &str,
)
Expand description

Emit mock server setup lines into a test function body.

Builds MockRoute objects from the fixture’s mock_response (single-response schema) or input.mock_responses (array schema for multiple responses per fixture). The resulting mock_server variable is in scope for the rest of the test function.

var_name controls the local binding name (e.g. "mock_server" when the rest of the test body references mock_server.url, "_mock_server" when the server only needs to be kept alive via Drop — typical for error-path fixtures that intentionally never read the URL). The underscore prefix silences -D unused_variables without dropping the server early.