OxL Reference

18.3 Mocks

oxl
mock Payments {
  charge(_)            => fail Timeout once, then Receipt{ id: 1 }
  refund(id) if id > 0 => Ok always
}
assert Payments.calls(.charge).count == 2
  • mock 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: mock and S.calls work for unary rpcs of services (not for interfaces and actors); in an integ cluster a mock acts on the test's node; S.calls(.m) is a List<Call> (it has .count).

mock-decl

See also

Source: docs/spec/oxl-standard.en.md