correio/capture

Explicitly owned, bounded local capture for application tests. Captured messages contain secrets; retrieval is an explicit inspection API.

Types

pub opaque type Capture

A position bound to one capture. Clearing retained messages does not rewind it.

pub opaque type Checkpoint

One retained delivery, identified within its capture lifetime.

pub type Entry {
  Entry(id: Int, message: message.Message)
}

Constructors

pub type Error {
  InvalidCapacity
  Unavailable
  DeadlineExceeded
}

Constructors

  • InvalidCapacity
  • Unavailable
  • DeadlineExceeded
pub type Handle

Values

pub fn checkpoint(capture: Capture) -> Result(Checkpoint, Error)

Record the current position before triggering the application flow under test.

pub fn clear(capture: Capture) -> Result(Nil, Error)
pub fn entries(capture: Capture) -> Result(List(Entry), Error)

Return retained entries in delivery order. Identifiers never repeat after clear.

pub fn messages(
  capture: Capture,
) -> Result(List(message.Message), Error)
pub fn send(
  capture: Capture,
  message: message.Message,
) -> delivery.Outcome
pub fn sender(
  capture: Capture,
) -> fn(message.Message) -> delivery.Outcome
pub fn since(
  checkpoint: Checkpoint,
) -> Result(List(message.Message), Error)

Return retained messages delivered after the checkpoint, in delivery order. Inspection does not consume messages. A checkpoint may be reused.

pub fn start(capacity: Int) -> Result(Capture, Error)

Start a capture owned by the calling process. The runtime exits when its owner exits. Capacity must be between 1 and 10,000 complete messages.

pub fn stop(capture: Capture) -> Result(Nil, Error)
✨ Search Document