Commits

Paul Gallagher  committed 8f9f3a6

change mysqlreader to take options object instead of db params

  • Participants
  • Parent commits 658875b

Comments (0)

Files changed (2)

File lib/mysql2psql/mysqlreader.rb

       connect
     end
   
-    def initialize(host = nil, user = nil, passwd = nil, db = nil, port = nil, sock = nil, flag = nil)
-      @host, @user, @passwd, @db, @port, @sock, @flag = host, user, passwd, db, port, sock, flag
+    def initialize(options)
+      @host, @user, @passwd, @db, @port, @sock, @flag = 
+        options.mysqlhostname('localhost'), options.mysqlusername, 
+        options.mysqlpassword, options.mysqldatabase, 
+        options.mysqlport, options.mysqlsocket
       connect
     end
   

File test/integration/mysqlreader_base_test.rb

 class MysqlreaderBaseTest < Test::Unit::TestCase
   attr_accessor :options
   def setup
-    @options = Mysql2psql::ConfigBase.new( "#{File.dirname(__FILE__)}/../fixtures/config_localmysql_to_file.yml" )
+    begin
+      configfile = "#{File.dirname(__FILE__)}/../fixtures/config_localmysql_to_file.yml"
+      @options = Mysql2psql::ConfigBase.new( configfile )
+    rescue
+      raise StandardError.new("Failed to initialize options from #{configfile}. See README for setup requirements.")
+    end
   end
-  def teardown
-    
+  def test_mysql_connection
+    assert_nothing_raised do
+      reader = Mysql2psql::MysqlReader.new(options)
+    end
   end
-  def test_db_connection
+  def test_mysql_reconnect
     assert_nothing_raised do
-      reader = Mysql2psql::MysqlReader.new(
-        options.mysqlhostname('localhost'), options.mysqlusername, options.mysqlpassword, 
-        options.mysqldatabase, options.mysqlport, options.mysqlsocket )
+      reader = Mysql2psql::MysqlReader.new(options)
+      reader.reconnect
     end
   end
 end