Skip to content

Commit 65b457c

Browse files
committed
Update example with start_owner!
1 parent 3865ff9 commit 65b457c

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/ecto/adapters/sql/sandbox.ex

Lines changed: 3 additions & 5 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
@@ -54,10 +56,6 @@ defmodule Ecto.Adapters.SQL.Sandbox do
5456
end
5557
end
5658
57-
If you run into issues with processes accessing your db after tests
58-
complete – e.g. ones stopped in `on_exit` callbacks – consider using
59-
`start_owner!/1` over `checkout/1`.
60-
6159
## Collaborating processes
6260
6361
The example above is straight-forward because we have only

0 commit comments

Comments
 (0)