Wrap all close() calls in "ensure" blocks and simplify DB connection-making.
[mailshears.git] / test / mailshears_test.rb
index 8e80c063f0a3a07092996d2eab49f82d50db5d8d..96a6e35e6c6ccf5343adca27d4a806031ce0ba33 100644 (file)
@@ -32,8 +32,8 @@ class MailshearsTest < MiniTest::Unit::TestCase
     db_user = 'postgres'
     db_pass = nil
 
-    connection = PGconn.connect(db_host, db_port, db_opts, db_tty,
-                                db_name, db_user, db_pass)
+    connection = PG::Connection.new(db_host, db_port, db_opts, db_tty,
+                                    db_name, db_user, db_pass)
 
     return connection
   end
@@ -206,9 +206,10 @@ class MailshearsTest < MiniTest::Unit::TestCase
       plugin_dbuser = cfg.send("#{plugin}_dbuser")
       plugin_dbpass = cfg.send("#{plugin}_dbpass")
 
-      plugin_conn = PGconn.connect(plugin_dbhost, plugin_dbport, plugin_dbopts,
-                                   plugin_dbtty, plugin_dbname, plugin_dbuser,
-                                   plugin_dbpass)
+      plugin_conn = PG::Connection.new(plugin_dbhost, plugin_dbport,
+                                       plugin_dbopts, plugin_dbtty,
+                                       plugin_dbname, plugin_dbuser,
+                                       plugin_dbpass)
 
       sql = File.open("test/sql/#{plugin}.sql").read()
       plugin_conn.query(sql)