based/testing

Types

A mock connection

pub type Connection {
  Connection(Subject(Message))
}

Constructors

  • Connection(Subject(Message))
pub type Message {
  Shutdown
  Insert(State)
  Get(
    reply_with: Subject(Result(List(Dynamic), BasedError)),
    key: String,
  )
}

Constructors

  • Shutdown
  • Insert(State)
  • Get(
      reply_with: Subject(Result(List(Dynamic), BasedError)),
      key: String,
    )
pub type State {
  State(init: Dict(String, List(Dynamic)))
}

Constructors

  • State(init: Dict(String, List(Dynamic)))

Functions

pub fn add(
  state: State,
  key: String,
  value: List(Dynamic),
) -> State
pub fn empty_returns_for(queries: List(Query)) -> State
pub fn insert(conn: Connection, state: State) -> Connection
pub fn mock_adapter(
  state: State,
) -> BasedAdapter(State, Connection, a)
pub fn mock_service(
  query: Query,
  conn: Connection,
) -> Result(List(Dynamic), BasedError)
pub fn new_state() -> State
pub fn with_connection(
  state: State,
  callback: fn(Connection) -> a,
) -> a

For testing code without hitting a real database

Search Document