Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Adds a test for timeout behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelBaker authored and ConnorRigby committed May 7, 2019
1 parent 7345e3f commit 685256f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/statement_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,24 @@ defmodule StatementTest do
result = Sqlitex.Statement.fetch_all(stmt, 1_000, :raw_list)
assert result == {:error, {:constraint, 'UNIQUE constraint failed: x.str'}}
end

test "custom query timeouts are passed through to esqlite" do
{:ok, db} = Sqlitex.open(":memory:")

{:error, reason, _} = catch_throw(
db
|> Sqlitex.Statement.prepare!("""
WITH RECURSIVE r(i) AS (
VALUES(0)
UNION ALL
SELECT i FROM r
LIMIT 1000000
)
SELECT i FROM r WHERE i = 1
""")
|> Sqlitex.Statement.fetch_all!(1)
)

assert reason == :timeout
end
end

0 comments on commit 685256f

Please sign in to comment.