Skip to content
Merged
Show file tree
Hide file tree
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
34 changes: 0 additions & 34 deletions integration_test/cases/prepare_stream_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -357,38 +357,4 @@ defmodule PrepareStreamTest do
handle_close: [%Q{}, _, :state2],
handle_commit: [_, :new_state2]] = A.record(agent)
end

test "prepare_stream declare log raises and deallocates" do
stack = [
{:ok, :state},
{:ok, :began, :new_state},
{:ok, %Q{}, :newer_state},
{:ok, %C{}, :newest_state},
{:ok, :deallocated, :state2},
{:ok, :commited, :new_state2}
]
{:ok, agent} = A.start_link(stack)

parent = self()
opts = [agent: agent, parent: parent]
{:ok, pool} = P.start_link(opts)

Process.flag(:trap_exit, true)
assert P.transaction(pool, fn(conn) ->
opts2 = [log: fn(_) -> raise "oops" end]
stream = P.prepare_stream(conn, %Q{}, [:param], opts2)
assert_raise RuntimeError, "oops", fn() -> Enum.to_list(stream) end
:hi
end) == {:ok, :hi}

assert [
connect: [_],
handle_begin: [_, :state],
handle_prepare: [%Q{}, _, :new_state],
handle_declare: [%Q{}, [:param], _, :newer_state],
handle_deallocate: [%Q{}, %C{}, _, :newest_state],
handle_commit: [_, :state2]
] = A.record(agent)
end

end
20 changes: 12 additions & 8 deletions integration_test/cases/stream_test.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
defmodule StreamTest do
use ExUnit.Case, async: true
import ExUnit.CaptureLog

alias TestPool, as: P
alias TestAgent, as: A
Expand Down Expand Up @@ -401,34 +402,37 @@ defmodule StreamTest do
{:handle_declare, [%Q{}, [:param], _, :new_state]} | _] = A.record(agent)
end

test "stream declare log raises and deallocates" do
test "stream declare log raises and continues" do
stack = [
{:ok, :state},
{:ok, :began, :new_state},
{:ok, %C{}, :newer_state},
{:ok, :deallocated, :newest_state},
{:ok, :commited, :state2}
{:deallocate, %R{}, :newest_state},
{:ok, :deallocated, :state2},
{:ok, :commited, :new_state2}
]
{:ok, agent} = A.start_link(stack)

parent = self()
opts = [agent: agent, parent: parent]
{:ok, pool} = P.start_link(opts)

Process.flag(:trap_exit, true)
assert P.transaction(pool, fn(conn) ->
opts2 = [log: fn(_) -> raise "oops" end]
opts2 = [log: fn(_) -> raise "logging oops" end]
stream = P.stream(conn, %Q{}, [:param], opts2)
assert_raise RuntimeError, "oops", fn() -> Enum.to_list(stream) end
assert capture_log(fn() ->
assert Enum.to_list(stream) == [%R{}]
end) =~ "logging oops"
:hi
end) == {:ok, :hi}

assert [
connect: [_],
handle_begin: [_, :state],
handle_declare: [%Q{}, [:param], _, :new_state],
handle_deallocate: [%Q{}, %C{}, _, :newer_state],
handle_commit: [_, :newest_state]
handle_first: [%Q{}, %C{}, _, :newer_state],
handle_deallocate: [%Q{}, %C{}, _, :newest_state],
handle_commit: [_, :state2]
] = A.record(agent)
end

Expand Down
2 changes: 1 addition & 1 deletion integration_test/cases/transaction_execute_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ defmodule TransactionExecuteTest do
end) == {:error, :oops}

assert_raise DBConnection.ConnectionError, "transaction rolling back",
fn() -> P.execute(conn, %Q{}, [:param]) end
fn() -> P.execute!(conn, %Q{}, [:param]) end
end) == {:error, :rollback}

assert [
Expand Down
Loading