In-memory implementation of the arke persistence contract, for test suites.
Arke core performs no I/O of its own; a persistence layer is injected through
config. This one keeps units in ETS instead of a database, so
QueryManager.get_by/1 and friends round-trip what was created and
validations that query (uniqueness, duplicate ids) actually work.
# config/test.exs
config :arke,
persistence: %{
arke_postgres: %{
create: &Arke.Test.Persistence.create/2,
update: &Arke.Test.Persistence.update/2,
update_key: &Arke.Test.Persistence.update_key/2,
delete: &Arke.Test.Persistence.delete/2,
execute_query: &Arke.Test.Persistence.execute/2,
get_parameters: &Arke.Test.Persistence.get_parameters/0,
create_project: &Arke.Test.Persistence.create_project/1,
delete_project: &Arke.Test.Persistence.delete_project/1
}
}Call setup/0 once from test_helper.exs, before any test runs, so the
table is owned by a process that outlives them. Arke.Test.Sandbox.restore/0
empties it between tests.
Summary
Functions
Drops every stored unit.
Creates the backing table. Idempotent.
Mirrors the adapter's update_key/2, which takes the current unit rather
than a project so the old row can be replaced when the id changes.
Functions
@spec create(atom(), Arke.Core.Unit.t()) :: {:ok, Arke.Core.Unit.t()}
@spec create_project(Arke.Core.Unit.t()) :: :ok
@spec delete(atom(), Arke.Core.Unit.t()) :: {:ok, nil}
@spec delete_project(Arke.Core.Unit.t()) :: :ok
@spec execute(Arke.Core.Query.t(), atom()) :: any()
@spec get_parameters() :: []
@spec reset() :: :ok
Drops every stored unit.
@spec setup() :: :ok
Creates the backing table. Idempotent.
@spec update(atom(), Arke.Core.Unit.t()) :: {:ok, Arke.Core.Unit.t()}
@spec update_key(Arke.Core.Unit.t(), Arke.Core.Unit.t()) :: {:ok, Arke.Core.Unit.t()}
Mirrors the adapter's update_key/2, which takes the current unit rather
than a project so the old row can be replaced when the id changes.