Skip to main content

Module cases

Module cases 

Source
Expand description

Case fixture model and JSON loader.

A Case is a sanitized HTTP transaction plus environmental Context. Each variant the diagnoser cares about lives as an explicit field — the struct is not a generic serde_json::Value bag, because we want serde to fail loudly when a fixture changes shape in a way the code didn’t expect.

Loading is gated on two checks (in order):

  1. The requested name is in KNOWN_CASES — see case_fixture_path.
  2. The loaded JSON’s name field matches the requested name — see load_case. A mismatch is a fixture-edit bug (CaseError::NameMismatch).

Bidirectional consistency between KNOWN_CASES and the on-disk fixtures/cases/*.json set is enforced by the known_cases_matches_on_disk_fixtures test below.

Structs§

Case
One sanitized HTTP transaction, plus environmental context, plus a pointer to the log file that recorded it.
Context
Environmental observations from the caller’s own network stack — things that don’t appear in the HTTP transaction itself.
Request
Sanitized HTTP request as authored in the fixture file.
Response
Sanitized HTTP response. Absent on Case (i.e. Case::response is None) for connection-layer failures where no response was received.

Enums§

CaseError
Errors the case loader can produce.

Constants§

KNOWN_CASES
Every case the binary knows how to load. Adding a new case requires:

Functions§

case_fixture_path
Look up the on-disk path for a known case name. Returns Err(Unknown) when the name is not in KNOWN_CASES.
load_case
Load a single case fixture by name from the given fixtures directory.
log_path_for
Resolve the log file path for a case, relative to the fixtures directory’s parent (so a case that records fixtures/logs/foo.log resolves correctly regardless of the current working directory).