Skip to content

Commit 074a271

Browse files
authored
Improve sandbox docs (#687)
1 parent e223a37 commit 074a271

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/ecto/adapters/sql/sandbox.ex

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ defmodule Ecto.Adapters.SQL.Sandbox do
4545
4646
setup do
4747
# Explicitly get a connection before each test
48-
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Repo)
48+
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(Repo)
49+
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)
50+
:ok
4951
end
5052
5153
test "create post" do
@@ -102,6 +104,9 @@ defmodule Ecto.Adapters.SQL.Sandbox do
102104
the parent's connection (i.e. the test process' connection) to
103105
the task.
104106
107+
Besides calling `allow/3` allowance can also be provided to processes
108+
via [Caller Tracking](`m:Task#module-ancestor-and-caller-tracking`).
109+
105110
Because allowances use an explicit mechanism, their advantage
106111
is that you can still run your tests in async mode. The downside
107112
is that you need to explicitly control and allow every single
@@ -148,7 +153,7 @@ defmodule Ecto.Adapters.SQL.Sandbox do
148153
149154
There are two mechanisms for explicit ownerships:
150155
151-
* Using allowances - requires explicit allowances via `allow/3`.
156+
* Using allowances - requires explicit allowances.
152157
Tests may run concurrently.
153158
154159
* Using shared mode - does not require explicit allowances.

0 commit comments

Comments
 (0)