# `Mediate.Test`
[🔗](https://github.com/mrmeku/mediate/blob/v0.1.0/lib/mediate/test.ex#L1)

Helpers every test tier and a third party's adapter suite share:

- the configuration override
- the clock a test sets
- the settle of the configured adapter's own state
- a poll with a deadline in place of a sleep

The core package ships them, so Tier 1 can run outside this repository.

# `accesses`

```elixir
@spec accesses((-&gt; term())) :: {term(), [map()]}
```

The access events the current process published while `fun` ran, in
order, with what `fun` returned. Only this process's reads count.

# `changes`

```elixir
@spec changes((-&gt; term())) :: {term(), [map()]}
```

The change events the current process published while `fun` ran, in
order, with what `fun` returned. Only this process's changes count, so
async tests never see one another's.

# `poll`

```elixir
@spec poll((-&gt; term()), pos_integer()) :: term()
```

Calls `fun` until it returns a truthy value or `timeout` milliseconds pass.
Returns the truthy value. Raises with the last value on timeout. This is
the one place the suite sleeps.

# `poll_interval`

```elixir
@spec poll_interval() :: pos_integer()
```

The poll interval, the floor of any measurement `poll/2` takes, in milliseconds.

# `queries`

```elixir
@spec queries(module(), (-&gt; term())) :: {term(), [String.t()]}
```

The SQL statements the current process ran on `repo` while `fun` ran, in
order. They come from the repo's `[..., :query]` telemetry, without
transaction control. Only this process's queries count, so async tests
never see one another's.

# `settle`

```elixir
@spec settle() :: :ok | :none
```

Bring the configured adapter's own state into step with the tables and
answer `:ok`. An adapter that keeps no state of its own has nothing to
settle, and the answer is `:none`. So a shared scenario can settle after
it writes facts without an adapter's name. A settle that fails raises
what it failed with, because a scenario that cannot settle cannot ask
its question.

# `with_config`

```elixir
@spec with_config(keyword()) :: :ok
```

Override configuration fields for the rest of the current process.
`Mediate.Config.resolve/0` reads the override from the caller and from
its `$callers` chain, over the boot struct when one exists.

# `with_config`

```elixir
@spec with_config(keyword(), (-&gt; result)) :: result when result: term()
```

Override configuration fields around a function, and restore the previous override after it.

---

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