ExGAM.Ledger.Store.Mock (ExGAM v0.1.0)

Copy Markdown View Source

Deterministic test adapter which wraps a real ledger Store.

The mock never reimplements ledger semantics. Unscripted calls are delegated to the configured Store, while scripted calls can replace a reply before the delegate runs or after it has run. The latter is useful for simulating a lost acknowledgement after a durable commit.

Scripts contain {operation, phase, reply} tuples. Supported operations are :append, :load, :lookup_batch, and :export; phases are :before and :after. Append scripts cannot synthesize a successful commit, and an after-append reply is used only when the delegate really succeeded. Each operation consumes its own script in insertion order.

Summary

Functions

Returns delegated calls in execution order.

Returns a specification to start this module under a supervisor.

Appends validated fault actions to the running script.

Starts a mock around the required :store adapter configuration.

Types

action()

@type action() :: {atom(), :before | :after, term()}

Functions

calls(server)

@spec calls(GenServer.server()) :: [map()]

Returns delegated calls in execution order.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

push(server, actions)

@spec push(GenServer.server(), action() | [action()]) :: :ok | {:error, term()}

Appends validated fault actions to the running script.

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

Starts a mock around the required :store adapter configuration.