# `EctoDoctor.RepeatedQueries.Assertions`
[🔗](https://github.com/Daniel-Brai/ecto-doctor/blob/v0.0.1/lib/ecto_doctor/repeated_queries/assertions.ex#L1)

Checks one block of code for N+1 queries inside an ExUnit test.

    import EctoDoctor.RepeatedQueries.Assertions

    test "lists posts", %{conn: conn} do
      assert_no_repeated_queries(fn -> get(conn, ~p"/posts") end)
    end

The block is scanned on its own so its queries don't count toward the test's own scan.

# `assert_no_repeated_queries`

```elixir
@spec assert_no_repeated_queries((-&gt; term())) :: :ok
```

Fails the test when the function runs an N+1 query and shows where it came from.

# `assert_repeated_queries`

```elixir
@spec assert_repeated_queries((-&gt; term())) :: :ok
```

Fails the test when the function runs no N+1 query, such as to prove the old code is still caught.

---

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