# `Snodo.Extensions.Tasks.Store.ContractTest`
[🔗](https://github.com/joshrotenberg/snodo/blob/v0.4.0/extensions/tasks/lib/snodo/extensions/tasks/store/contract_test.ex#L1)

Reusable ExUnit checks for a `Snodo.Extensions.Tasks.Store` implementation.

Use this module inside an `ExUnit.Case` and pass `:start_store`, an arity-2
function receiving the test context and store options. It must return a
fresh `{module, state}` reference. The suite passes `:max_tasks` and
`:max_active_tasks_per_scope` to check capacity. Start a store with a scope
function based on `context.auth["tenant"]`; each test uses distinct tenant
values. The function may register cleanup with `on_exit/1`.

    use ExUnit.Case, async: false
    use Snodo.Extensions.Tasks.Store.ContractTest,
      start_store: &__MODULE__.start_contract_store/2

A store whose concurrent writers can be refused with a documented, retryable
backpressure result passes `:retryable?`, an arity-1 function that returns
true for such a result. The capacity check races two creations; a creation
refused that way is retried once after the race, so the check still requires
exactly one creation and one capacity refusal. Without `:retryable?`, no
result is retried.

    use Snodo.Extensions.Tasks.Store.ContractTest,
      start_store: &__MODULE__.start_contract_store/2,
      retryable?: &(&1 == {:error, :database_busy})

The suite checks the public store boundary. Run backend-specific persistence,
restart, database transaction, and stress tests alongside it.

# `__using__`
*macro* 

Injects the shared store contract tests into an ExUnit case.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
