Freddy.Adapter.Sandbox (freddy v0.16.0)

Special no-op Freddy adapter designed to be used in automated tests instead of real AMQP connection.

Example

iex> alias Freddy.{Connection, Core.Exchange, Adapter.Sandbox}
iex> {:ok, conn} = Connection.start_link(adapter: :sandbox)
iex> {:ok, channel} = Connection.open_channel(conn)
iex> :ok = Exchange.declare(%Exchange{name: "test"}, channel)
iex> {:ok, pid} = Connection.get_connection(conn)
iex> Sandbox.history(pid)
[
  link_connection: [#PID<0.226.0>],
  open_channel: [#PID<0.226.0>],
  monitor_channel: [#PID<0.228.0>],
  declare_exchange: [#PID<0.228.0>, "test", :direct, []]
]

Link to this section Summary

Functions

Get history of events from connection. Events can be filtered by type, for example, if one wants to get only history of messages, published over given connection, he should call history(connection, :publish). Filter by multiple event types is supported.

Sets a response for open_channel/1 function. If set to :ok, the function will return a tuple {:ok, channel_pid} (default behaviour).

Link to this section Functions

Link to this function

history(connection, events \\ :all, flush? \\ false)

Get history of events from connection. Events can be filtered by type, for example, if one wants to get only history of messages, published over given connection, he should call history(connection, :publish). Filter by multiple event types is supported.

Passing true as a third argument will erase entire history after returning it.

Link to this function

on_open_channel(connection, response)

Sets a response for open_channel/1 function. If set to :ok, the function will return a tuple {:ok, channel_pid} (default behaviour).