Issho.Test (Issho v0.1.0)

Copy Markdown View Source

Helpers for testing an app or a binding with Issho, in ExUnit.

setup do
  instance = Issho.Test.start!(policy: MyApp.Collaboration)
  %{instance: instance}
end

test "an agent drafts a title", %{instance: instance} do
  {:ok, agent} = Issho.join_as(instance, %{id: "agent:1", kind: :agent}, "board:1")
  {:ok, _} = Issho.Participant.open(agent, "board:1")
  {:ok, _} = Issho.Participant.transact(agent, "board:1", ops)
  assert Issho.Test.replays?(instance, "board:1")
end

start!/1 starts an isolated instance for the test: its own PubSub, a store in memory, quick awareness frames, and no Issho.Presence unless you ask (presence: true; only one runs on a node).

Summary

Functions

Whether replaying a document's journal from the start of its epoch gives its current content: the engine is deterministic, and nothing changed the state outside a transaction. A conformance check for engines.

Starts an isolated instance under the test's supervisor and gives its name. Options: :policy (required), and any option of Issho.

Functions

replays?(instance, document_id)

@spec replays?(atom(), String.t()) :: boolean()

Whether replaying a document's journal from the start of its epoch gives its current content: the engine is deterministic, and nothing changed the state outside a transaction. A conformance check for engines.

start!(opts)

@spec start!(keyword()) :: atom()

Starts an isolated instance under the test's supervisor and gives its name. Options: :policy (required), and any option of Issho.