pub struct MockDecl {
pub name: Option<String>,
pub matcher: MockMatch,
pub stub: Option<StubSpec>,
pub deny: Option<DenySpec>,
pub rewrite: Option<Value>,
}Expand description
One mock or spy declaration — an entry of a test case’s mocks: block, of
the CLI’s --mocks file, or synthesized by an SDK. Exactly one of stub /
deny / rewrite makes it a mock (the call is intercepted); none makes
it a spy (observed only, matched locally against the returned records).
Fields§
§name: Option<String>Name evals (type: called / not_called) reference this declaration
by. Optional; unnamed declarations get a positional fallback
(mock_<i> / spy_<i>) used in reports and error messages.
matcher: MockMatch§stub: Option<StubSpec>Fake a shell call’s result: the real command never runs and the model receives this output as the tool’s genuine result.
deny: Option<DenySpec>Block the call; the model reads the message as the tool’s feedback.
rewrite: Option<Value>Substitute raw input fields (a JSON object) — the low-level escape
hatch, and the way to mock file reads (rewrite file_path to a
fixture).
Implementations§
Source§impl MockDecl
impl MockDecl
Sourcepub fn is_mock(&self) -> bool
pub fn is_mock(&self) -> bool
Whether this declaration intercepts (has an action) or only observes.
Sourcepub fn validate(&self, who: &str) -> Result<()>
pub fn validate(&self, who: &str) -> Result<()>
Validate the declaration, identified as who in errors.
§Errors
Error::Invalid on an empty name, an invalid matcher, more than one
action, or a non-object rewrite.
Sourcepub fn action_kind(&self) -> Option<&'static str>
pub fn action_kind(&self) -> Option<&'static str>
The action’s stable token (stub/deny/rewrite), or None for a spy.