Commits

Paul Gallagher committed 361613f

basic postgres_db_writer test

Comments (0)

Files changed (5)

test/fixtures/config_localmysql_to_db_convert_all.yml

+mysql:
+ hostname: localhost
+ port: 3306
+ socket: /tmp/mysql.sock
+ username: mysql2psql
+ password: 
+ database: mysql2psql_test
+
+destination:
+ # if file is given, output goes to file, else postgres
+ file:
+ postgres:
+  hostname: localhost
+  port: 5432
+  username: mysql2psql
+  password: 
+  database: mysql2psql_test
+
+# if tables is given, only the listed tables will be converted.  leave empty to convert all tables.
+#tables:
+#- notexist
+
+# if exclude_tables is given, exclude the listed tables from the conversion.
+#exclude_tables:
+#- table5
+#- table6
+
+# if supress_data is true, only the schema definition will be exported/migrated, and not the data
+supress_data: false
+
+# if supress_ddl is true, only the data will be exported/imported, and not the schema
+supress_ddl: false
+
+# if force_truncate is true, forces a table truncate before table loading
+#force_truncate: true

test/integration/convert_to_db_test.rb

       seed_test_database
       @@mysql2psql = Mysql2psql.new([configfile])
       @@mysql2psql.convert
+      @@mysql2psql.writer.open
     end
     def shutdown
+      @@mysql2psql.writer.close
     end
   end
   def setup
   def teardown
   end
 
+  def test_table_creation
+    assert_true @@mysql2psql.writer.exists?('numeric_types_basics')
+  end
 
 end

test/integration/mysqlreader_base_test.rb

 
 class MysqlreaderBaseTest < Test::Unit::TestCase
   attr_accessor :options
+  class << self
+    def startup
+      seed_test_database
+      @@options = get_test_config( 'config_localmysql_to_file_convert_nothing.yml' )
+    end
+    def shutdown
+    end
+  end
   def setup
-    seed_test_database
-    @options = get_test_config( 'config_localmysql_to_file_convert_nothing.yml' )
+  end
+  def teardown
+  end
+  def options
+    @@options
   end
   
   def test_mysql_connection

test/integration/mysqlreader_test.rb

 
 class MysqlreaderTest < Test::Unit::TestCase
   attr_accessor :reader
+  class << self
+    def startup
+      seed_test_database
+      @@reader=get_test_reader(get_test_config('config_localmysql_to_file_convert_nothing.yml'))
+    end
+    def shutdown
+    end
+  end
   def setup
-    seed_test_database
-    @reader=get_test_reader(get_test_config('config_localmysql_to_file_convert_nothing.yml'))
   end
   def teardown
   end
+  def reader
+    @@reader
+  end
   
   def test_db_connection
     assert_nothing_raised do

test/integration/postgres_db_writer_base_test.rb

+require 'test_helper'
+
+require 'mysql2psql'
+
+class PostgresDbWriterBaseTest < Test::Unit::TestCase
+  attr_accessor :options
+  class << self
+    def startup
+      seed_test_database
+    end
+    def shutdown
+    end
+  end
+  def setup
+
+  end
+  
+  def test_pg_connection
+  end
+
+end