Skip to content

Commit

Permalink
Merge pull request #180 from loe/0.2.x
Browse files Browse the repository at this point in the history
0.2.x test for issue #99
  • Loading branch information
brianmario committed Jun 16, 2011
2 parents 4e84430 + bf6bccd commit dd8d99c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions spec/mysql2/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,33 @@ def connect *args
}.should raise_error(Mysql2::Error)
end

it "should close the connection when an exception is raised" do
begin
Timeout.timeout(1) do
@client.query("SELECT sleep(2)")
end
rescue Timeout::Error
end

lambda {
@client.query("SELECT 1")
}.should raise_error(Mysql2::Error, 'closed MySQL connection')
end

it "should handle Timeouts without leaving the connection hanging if reconnect is true" do
client = Mysql2::Client.new(:reconnect => true)
begin
Timeout.timeout(1) do
client.query("SELECT sleep(2)")
end
rescue Timeout::Error
end

lambda {
client.query("SELECT 1")
}.should_not raise_error(Mysql2::Error)
end

it "threaded queries should be supported" do
threads, results = [], {}
connect = lambda{ Mysql2::Client.new(:host => "localhost", :username => "root") }
Expand Down

0 comments on commit dd8d99c

Please sign in to comment.