Skip to main content

Module document

Module document 

Source
Expand description

Scenario document model, parsing, and validation (ADR-0069 sections 1-2).

A scenario document is a .test.yaml (or .test.yml) sidecar that declares one integration-tier test: exactly one route source (routeFiles, routeFilesFromRoot, or inline routes), an ordered scenario: action list, an optional env: map with fixed fixture values, an optional envPassthrough: allowlist, an optional endpoint-keyed partners: scripting map, an optional pinned profile, an optional document-level sendDeadline bounding every send, an optional document-level inbound: listener declaration (feature http), and an optional document-level logs: assertion block (rc-tdgh5) whose grammar is clause-checked here and evaluated against the harness capture window at run time. Unknown fields are rejected.

The scenario vocabulary and the unit-tier vocabulary (inputs, expects, intercepts) never mix in one document. A document with scenario: that also declares a unit-tier section is rejected at load time.

Durations (sendDeadline, deadline, duration, elapsedAtLeast) are humantime strings, for example "5s" or "250ms", parsed during validation so errors can name the action index.

Re-exports§

pub use error::DocError;
pub use logs::LogLevel;
pub use logs::LogsAssertion;
pub use validate::ScenarioTarget;
pub use validate::SqlTarget;
pub use validate::ValidateExpectation;

Modules§

error
Load-time errors for scenario documents, and the endpoint-reference conversion that fails with them (rc-0ahfl, split out of the parent module).
logs
The document-level logs: assertion grammar (rc-p1x2a, split out of the parent module; mirrors the document/error.rs pattern).
validate
The validate grammar: what a validate action asserts against (target), the paired expectation shapes, and the expectation parsers (bd rc-m6xr, split out of the parent module; mirrors the document/error.rs and partner_script.rs patterns).

Structs§

EndpointRef
An endpoint reference: a bare endpoint string or a map with endpoint, provisioning, and bindVar keys.
InboundListener
The document’s inbound: declaration (rc-5yon): v1 grammar is a single map inbound: {bindVar: NAME}. The harness provisions one listener per document, binds 127.0.0.1:0, stages it on the HTTP component’s global registry (ADR-0070 staged consumption), and fills the bind variable with http://<bound-address> so route consumer URIs interpolate the staged socket.
PartnerExpectation
A recorded-request expectation: a count bound plus optional method, path, and query subset filters.
PartnerScript
One partner script of a partners: entry: the response a partner serves when the system under test reaches its endpoint, or the fault it applies instead. Exactly one of response / fault must be declared. Grammar only; the runner consumes the map.
PartnerScriptResponse
The response a partner script serves.
RowsExpectation
The sql-target row-shape expectation: exactly one row shape is populated at parse time — concrete row patterns or a row-count bound (rows XOR bound).
ScenarioDocument
A parsed scenario document. Route file paths stay as declared; resolving them against the document directory or the project root is the runner’s job, the same split the unit-tier parser keeps.

Enums§

CountBound
The recorded-request count bound of a RequestExpectation: exactly one bound form per expectation. Poll semantics per bound (arrivals only add, so the filtered count is monotone non-decreasing):
Expectation
A validation expectation. The grammar keys mirror the mock-testkit matcher rules: equals, regex, contains, startsWith, endsWith, exists, jsonSubset.
PartnerFault
The fault a partner script applies instead of serving a response.
PathFilter
The path filter of a RequestExpectation over the recorded path-and-query; at most one filter per expectation.
Provisioning
Partner provisioning source (ADR-0069 section 9). The axis is who owns the lifecycle. testcontainer and user-provided are reserved grammar values; the parser rejects them.
RouteSource
The route source of a scenario document. Exactly one form is declared; the parser rejects zero or multiple declarations.
ScenarioAction
One ordered scenario action (ADR-0069 section 11, adopted from Citrus: send, receive with a mandatory deadline, sleep, validate, sql).

Functions§

parse_scenario_document
Parses and validates a scenario document. Validation order: (a) the path carries a reserved test-document suffix; (b) the text deserializes; (c) a non-empty scenario: section exists; (d) no unit-tier section coexists with it; (e) exactly one route source is declared, and it is not inline (routes cannot boot in v1, so the defect fails at load instead of at boot); (f) each action converts (single-key dispatch, deadlines, durations, endpoint provisioning, expectation grammar, the direct:-only expectReply gate) with action-index errors; (g) each partners entry converts (script grammar, response status range) with entry-key errors; (h) no env key collides with a declared bindVar; (i) each partner validate target URI equals a harness endpoint reference declared by the scenario’s own send/receive actions, or self-declares the reference: an object-form provisioning: harness target whose http URI a partners: entry names. The optional inbound: section converts between (g) and (h): grammar in every build, activation demand-gated behind http (ADR-0069 §8). (j) The optional logs: block converts (clause grammar: contains markers, load-compiled regex, the noLevelAbove level set) with clause-naming load errors.