Jido.Chat.AdapterTestKit.MockState (Jido Chat v1.2.0)

Copy Markdown View Source

A small deterministic state process for adapter tests.

Each process keeps its initial snapshot so a test can reset it without global application state.

Summary

Functions

Returns a specification to start this module under a supervisor.

Gets one key from the current state.

Puts one key in the current state.

Restores the initial state snapshot.

Returns the current state snapshot.

Starts a mock state process.

Updates the current state and returns the new snapshot.

Types

server()

@type server() :: GenServer.server()

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get(server, key, default \\ nil)

@spec get(server(), term(), term()) :: term()

Gets one key from the current state.

put(server, key, value)

@spec put(server(), term(), term()) :: :ok

Puts one key in the current state.

reset(server)

@spec reset(server()) :: :ok

Restores the initial state snapshot.

snapshot(server)

@spec snapshot(server()) :: map()

Returns the current state snapshot.

start_link(opts \\ [])

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

Starts a mock state process.

update(server, fun)

@spec update(server(), (map() -> map())) :: map()

Updates the current state and returns the new snapshot.