LatticeStripe.Testing.TestClock.Owner (LatticeStripe v1.7.10)

Copy Markdown View Source

GenServer-backed registry that owns per-test LatticeStripe.Testing.TestClock ids so integration tests can isolate time-travel state.

The Owner tracks clock ids created during a single test and deletes them on cleanup/2 (invoked from an on_exit callback), mirroring the pattern used by Ecto.Adapters.SQL.Sandbox.start_owner!/2. The Owner is intentionally NOT start_supervised! — it must outlive the test pid so on_exit can still delete clocks even when the test crashes or raises.

Usage

The Owner is started automatically by LatticeStripe.Testing.TestClock.test_clock/1 and should not be called directly by application code.

Summary

Functions

Returns a specification to start this module under a supervisor.

Best-effort delete of every registered clock, then stops the owner.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

cleanup(owner, client)

@spec cleanup(pid(), LatticeStripe.Client.t()) :: :ok

Best-effort delete of every registered clock, then stops the owner.

Errors from individual delete/3 calls are swallowed — the Mix task is the backstop. Called from an on_exit callback after the test exits.

register(owner, clock_id)

@spec register(pid(), String.t()) :: :ok

registered(owner)

@spec registered(pid()) :: [String.t()]

start_owner!(opts \\ [])

@spec start_owner!(keyword()) :: pid()