forked from elixir-ecto/ecto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
isolation_test.exs
37 lines (30 loc) · 1.03 KB
/
isolation_test.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
defmodule Ecto.Integration.IsolationTest do
use Ecto.Integration.Case, async: true
alias Ecto.Integration.PoolRepo
alias Ecto.Integration.TestRepo
alias Ecto.Integration.Post
test "aborts on corrupted transactions" do
PoolRepo.transaction fn ->
{:error, _} = PoolRepo.query("INVALID")
end
PoolRepo.transaction fn ->
# This will taint the whole inner transaction
{:error, _} = PoolRepo.query("INVALID")
assert_raise Postgrex.Error, ~r/current transaction is aborted/, fn ->
PoolRepo.insert(%Post{}, skip_transaction: true)
end
end
end
test "aborts on corrupted transactions even inside sandboxes" do
TestRepo.transaction fn ->
{:error, _} = TestRepo.query("INVALID")
end
TestRepo.transaction fn ->
# This will taint the whole inner transaction
{:error, _} = TestRepo.query("INVALID")
assert_raise Postgrex.Error, ~r/current transaction is aborted/, fn ->
TestRepo.insert(%Post{}, skip_transaction: true)
end
end
end
end