Skip to main content

Fixture

Struct Fixture 

Source
pub struct Fixture {
Show 21 fields pub id: String, pub category: Option<String>, pub description: String, pub docs: Option<FixtureDocs>, pub requirements: Vec<String>, pub tags: Vec<String>, pub skip: Option<SkipDirective>, pub env: Option<FixtureEnv>, pub setup: Vec<SetupCall>, pub call: Option<String>, pub input: Value, pub preserve_input_urls: bool, pub mock_response: Option<MockResponse>, pub visitor: Option<VisitorSpec>, pub args: Vec<ArgMapping>, pub assertion_recipes: Vec<String>, pub assertions: Vec<Assertion>, pub source: String, pub http: Option<HttpFixture>, pub asyncapi: Option<AsyncApiFixture>, pub websocket: Option<WebSocketFixture>,
}
Expand description

A single e2e test fixture.

Fields§

§id: String

Unique identifier (used as test function name).

§category: Option<String>

Optional category (defaults to parent directory name).

§description: String

Human-readable description.

§docs: Option<FixtureDocs>§requirements: Vec<String>

Declarative capabilities required to publish this fixture as a snippet.

§tags: Vec<String>§skip: Option<SkipDirective>§env: Option<FixtureEnv>

Environment variable requirements (used by smoke/live tests).

§setup: Vec<SetupCall>

Setup calls executed before the main call (used to register backends, etc).

§call: Option<String>

Named call config to use (references [e2e.calls.<name>]). When omitted, uses the default [e2e.call].

§input: Value

Input data passed to the function under test.

§preserve_input_urls: bool

Pass this fixture’s declared URLs to the call verbatim instead of substituting the mock server address.

~keep mock_url and mock_url_list arguments normally ignore input.url / input.urls entirely and bind the per-fixture mock server address, because almost every fixture wants a live server to talk to. A minority of fixtures are testing the address itself — SSRF policy, scheme rejection, host parsing — and for those the substitution silently replaces the subject of the test, so several fixtures declaring different addresses all end up exercising one trivial case and passing for the wrong reason.

This is opt-in per fixture rather than inferred: an “is it absolute?” heuristic would reclassify existing fixtures that legitimately declare an absolute URL next to a mock server, changing their meaning without anyone editing them.

§mock_response: Option<MockResponse>

Optional mock HTTP response for testing HTTP clients.

§visitor: Option<VisitorSpec>

Optional visitor specification for visitor pattern tests.

§args: Vec<ArgMapping>

Fixture-level argument mappings. When non-empty, overrides call_config.args for this specific fixture (used for trait-bridge stubs and other per-fixture args).

§assertion_recipes: Vec<String>

Assertion recipes this fixture opts into.

Domain-shaped assertions such as embeddings, keyword extraction, tree-query helpers, and streaming pseudo-fields require an explicit recipe opt-in so generic e2e fixtures don’t silently inherit project-specific assumptions.

§assertions: Vec<Assertion>

List of assertions to check.

§source: String

Source file path (populated during loading).

§http: Option<HttpFixture>

HTTP server test specification. When present, this fixture tests an HTTP handler rather than a function call.

§asyncapi: Option<AsyncApiFixture>§websocket: Option<WebSocketFixture>

Implementations§

Source§

impl Fixture

Source

pub fn docs_client(&self) -> Option<&FixtureDocsClient>

The client construction this fixture’s documentation snippet must use, if it declares one.

This is docs-only and is deliberately not folded into Fixture::docs_call_fixture’s returned value: the fixture it returns is fed to renderers that also serve the executable e2e suite, where retargeting the client away from the mock server would silently turn a real test into a call against the illustrative endpoint the prose is about. Generators must therefore pass this value in explicitly from a documentation-only call site.

Source

pub fn docs_call_fixture(&self) -> Self

Source

pub fn docs_files_for_arg(&self, field: &str) -> Vec<FixtureDocsFileInput>

Source

pub fn docs_file_path(&self, field: &str) -> Option<String>

Source

pub fn has_docs_presentation(&self) -> bool

Source

pub fn resolved_args<'a>( &'a self, call_config: &'a CallConfig, ) -> &'a [ArgMapping]

Resolve the effective args for this fixture, preferring fixture-level args when present.

When self.args is non-empty, returns a reference to it. Otherwise, returns a reference to call_config.args. This allows fixtures to override the call’s default args (e.g., for trait-bridge stubs that need per-fixture test backend setup).

Source

pub fn is_http_test(&self) -> bool

Returns true if this is an HTTP server test fixture.

Source

pub fn needs_mock_server(&self) -> bool

Returns true if this fixture requires a mock HTTP server. This is true when the fixture declares a single mock response, an HTTP expected response, or one or more entries in the generic input.mock_responses route array.

Source

pub fn as_mock_response(&self) -> Option<MockResponse>

Returns the effective mock response for this fixture, bridging both schemas:

  • call fixture schema: mock_response: { status, body, stream_chunks }
  • HTTP fixture schema: http.expected_response: { status_code, body, headers }

Returns None if neither schema is present.

Source

pub fn is_streaming_mock(&self) -> bool

Returns true if the mock response uses streaming (SSE).

Source

pub fn has_host_root_route(&self) -> bool

Returns true if this fixture needs a dedicated origin-root listener.

Route-array fixtures are normally mounted under /fixtures/<id> in the shared mock server. A dedicated listener is required when a route path or fixture body makes the client under test resolve follow-up requests from the origin root rather than the fixture namespace. Mirrors the is_host_root_path predicate in the standalone mock-server binary (codegen/rust/mock_server.rs).

Origin-root fixtures get a dedicated per-fixture listener and their base URL is published in the MOCK_SERVERS={"fixture_id":"http://..."} JSON line.

Source

pub fn resolved_category(&self) -> String

Get the resolved category (explicit or from source directory).

Trait Implementations§

Source§

impl Clone for Fixture

Source§

fn clone(&self) -> Fixture

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Fixture

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Fixture

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Fixture

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Fixture

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more