18.3 Mocks
mock Payments {
charge(_) => fail Timeout once, then Receipt{ id: 1 }
refund(id) if id > 0 => Ok always
}
assert Payments.calls(.charge).count == 2mock S { … }replaces a service, interface or actor within a test. A branch: an argument pattern (§5.5)=>a sequence of responses:e once,e times n,then e,e always. By default the last response is repeated.- A call that matches no branch fails the test with a description of the call.
S.calls(.method) -> List<Call>: arguments,ctx, time.
Implementation-defined. Limits of
mock(D-8056; DIV-037; D-7250). This implementation:mockandS.callswork for unary rpcs of services (not for interfaces and actors); in anintegcluster a mock acts on the test's node;S.calls(.m)is aList<Call>(it has.count).
Related diagnostics
See also
Source: docs/spec/oxl-standard.en.md