diff options
-rw-r--r-- | activerecord/test/connection_test_firebird.rb | 4 | ||||
-rw-r--r-- | activerecord/test/connection_test_mysql.rb | 30 |
2 files changed, 32 insertions, 2 deletions
diff --git a/activerecord/test/connection_test_firebird.rb b/activerecord/test/connection_test_firebird.rb index 4760a46dbc..715e695518 100644 --- a/activerecord/test/connection_test_firebird.rb +++ b/activerecord/test/connection_test_firebird.rb @@ -1,6 +1,6 @@ -require 'abstract_unit' +require "#{File.dirname(__FILE__)}/abstract_unit" -class ConnectionTest < Test::Unit::TestCase +class FirebirdConnectionTest < Test::Unit::TestCase def test_charset_properly_set fb_conn = ActiveRecord::Base.connection.instance_variable_get(:@connection) assert_equal 'UTF8', fb_conn.database.character_set diff --git a/activerecord/test/connection_test_mysql.rb b/activerecord/test/connection_test_mysql.rb new file mode 100644 index 0000000000..e3f589c4af --- /dev/null +++ b/activerecord/test/connection_test_mysql.rb @@ -0,0 +1,30 @@ +require "#{File.dirname(__FILE__)}/abstract_unit" + +class MysqlConnectionTest < Test::Unit::TestCase + def setup + @connection = ActiveRecord::Base.connection + end + + def test_no_automatic_reconnection_after_timeout + assert @connection.active? + @connection.update('set @@wait_timeout=1') + sleep 2 + assert !@connection.active? + end + + def test_successful_reconnection_after_timeout_with_manual_reconnect + assert @connection.active? + @connection.update('set @@wait_timeout=1') + sleep 2 + @connection.reconnect! + assert @connection.active? + end + + def test_successful_reconnection_after_timeout_with_verify + assert @connection.active? + @connection.update('set @@wait_timeout=1') + sleep 2 + @connection.verify!(0) + assert @connection.active? + end +end |