Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/ecto/adapters/sql/sandbox.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ defmodule Ecto.Adapters.SQL.Sandbox do

setup do
# Explicitly get a connection before each test
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Repo)
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(Repo)
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)
:ok
end

test "create post" do
Expand Down Expand Up @@ -102,6 +104,9 @@ defmodule Ecto.Adapters.SQL.Sandbox do
the parent's connection (i.e. the test process' connection) to
the task.

Besides calling `allow/3` allowance can also be provided to processes
via [Caller Tracking](`m:Task#module-ancestor-and-caller-tracking`).

Because allowances use an explicit mechanism, their advantage
is that you can still run your tests in async mode. The downside
is that you need to explicitly control and allow every single
Expand Down Expand Up @@ -148,7 +153,7 @@ defmodule Ecto.Adapters.SQL.Sandbox do

There are two mechanisms for explicit ownerships:

* Using allowances - requires explicit allowances via `allow/3`.
* Using allowances - requires explicit allowances.
Tests may run concurrently.

* Using shared mode - does not require explicit allowances.
Expand Down
Loading