Skip to content

Commit

Permalink
Test with reconnect => true, common in Rails.
Browse files Browse the repository at this point in the history
  • Loading branch information
loe committed Jun 16, 2011
1 parent 27fe0da commit bf6bccd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/mysql2/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,20 @@ def connect *args
}.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 bf6bccd

Please sign in to comment.