Per-test ETS table management for async-safe isolation.
Summary
Functions
Create an isolated ETS table with automatic cleanup.
Get the mirror table for a source table.
Get the mirror table or raise if not found.
Temporarily replace a module's table reference.
Create an isolated copy of an existing named table.
Initialize ETS isolation for the current process.
Initialize ETS isolation and optionally auto-mirror tables or update context.
Initialize ETS isolation, auto-mirror tables, and update context.
Execute a function with a temporary ETS table that is deleted after scope.
Types
@type create_opts() :: [table_option() | create_opt()]
@type inject_opt() :: {:create, boolean()} | {:table_opts, [table_option()]} | {:cleanup, boolean()}
@type inject_opts() :: [inject_opt()]
@type mirror_opt() :: {:include_data, boolean()} | {:access, table_access()} | {:cleanup, boolean()}
@type mirror_opts() :: [mirror_opt()]
@type table_access() :: :public | :protected | :private
@type table_name() :: atom()
@type table_option() :: table_type() | table_access() | :named_table | {:keypos, pos_integer()} | {:heir, pid(), term()} | {:write_concurrency, boolean()} | {:read_concurrency, boolean()} | :compressed
@type table_type() :: :set | :ordered_set | :bag | :duplicate_bag
Functions
@spec create_isolated(table_type(), create_opts()) :: {:ok, table_ref()}
Create an isolated ETS table with automatic cleanup.
@spec get_mirror(table_name()) :: {:ok, table_ref()} | {:error, :not_mirrored}
Get the mirror table for a source table.
@spec get_mirror!(table_name()) :: table_ref()
Get the mirror table or raise if not found.
@spec inject_table(module(), atom(), table_name() | table_ref(), inject_opts()) :: {:ok, (-> :ok)}
Temporarily replace a module's table reference.
@spec mirror_table(table_name(), mirror_opts()) :: {:ok, table_ref()} | {:error, {:table_not_found, table_name()}}
Create an isolated copy of an existing named table.
@spec setup_ets_isolation() :: :ok
Initialize ETS isolation for the current process.
@spec setup_ets_isolation([table_name()]) :: :ok
@spec setup_ets_isolation(Supertester.IsolationContext.t()) :: {:ok, Supertester.IsolationContext.t()}
Initialize ETS isolation and optionally auto-mirror tables or update context.
@spec setup_ets_isolation(Supertester.IsolationContext.t(), [table_name()]) :: {:ok, Supertester.IsolationContext.t()}
Initialize ETS isolation, auto-mirror tables, and update context.
@spec with_table(table_type(), (table_ref() -> term())) :: term()
Execute a function with a temporary ETS table that is deleted after scope.
@spec with_table(table_type(), create_opts(), (table_ref() -> term())) :: term()