]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - test/mailshears_test.rb
mailshears.gemspec: bump version to 0.1.0
[mailshears.git] / test / mailshears_test.rb
index 2b653ede18100dc64e4afcaaaef3f757ebc8b8f6..215d05f0b21f93b0fdf25f4f237da63823379693 100644 (file)
@@ -11,7 +11,7 @@ require 'common/configuration'
 require 'fileutils'
 require 'pg'
 
 require 'fileutils'
 require 'pg'
 
-class MailshearsTest < MiniTest::Test
+class MailshearsTest < Minitest::Test
   # This is that class that most (if not all) of our test cases will
   # inherit. It provides the automatic setup and teardown of the
   # filesystem and database that the test cases will exercise.
   # This is that class that most (if not all) of our test cases will
   # inherit. It provides the automatic setup and teardown of the
   # filesystem and database that the test cases will exercise.
@@ -32,16 +32,15 @@ class MailshearsTest < MiniTest::Test
     # Connect to the database (specified in the test configuration) as
     # the superuser. Your local configuration is expected to be such
     # that this "just works."
     # Connect to the database (specified in the test configuration) as
     # the superuser. Your local configuration is expected to be such
     # that this "just works."
-    db_host = 'localhost'
-    db_port = 5432
-    db_opts = nil
-    db_tty = nil
-    db_name = 'postgres'
-    db_user = 'postgres'
-    db_pass = nil
-
-    connection = PG::Connection.new(db_host, db_port, db_opts, db_tty,
-                                    db_name, db_user, db_pass)
+    db_hash = {
+      :host     => 'localhost',
+      :port     => 5432,
+      :options  => nil,
+      :dbname   => 'postgres',
+      :user     => 'postgres',
+      :password => nil
+    }
+    connection = PG::Connection.new(db_hash)
 
     return connection
   end
 
     return connection
   end
@@ -66,31 +65,7 @@ class MailshearsTest < MiniTest::Test
     #
     # == Databases ==
     #
     #
     # == Databases ==
     #
-    # 1. agendav_test
-    #
-    #   +------------------------------+
-    #   |              prefs           |
-    #   +--------------------+---------+
-    #   |      username      | options |
-    #   +--------------------+---------+
-    #   |  adam@example.net  | herp    |
-    #   +--------------------+---------+
-    #   | booger@example.com | herp    |
-    #   +------------------  +---------+
-    #
-    #
-    #   +---------------------------------------------------------------------------------------------------------------------+
-    #   |                                                       shares                                                        |
-    #   +-----+-----------------------------------+---------------------------------------------------+-----------------------+
-    #   | sid |              owner                |                      calendar                     |          with         |
-    #   +-----+-----------------------------------+---------------------------------------------------+-----------------------+
-    #   |   1 | /caldav.php/adam%40example.net/   | /caldav.php/adam%40example.net/calendar-default   | /beth%40example.net/  |
-    #   +-----+-----------------------------------+---------------------------------------------------+-----------------------+
-    #   |   2 | /caldav.php/booger%40example.com/ | /caldav.php/booger%40example.com/calendar-default | /carol%40example.net/ |
-    #   +-----+-----------------------------------+---------------------------------------------------+-----------------------+
-    #
-    #
-    # 2. davical_test
+    # 1. davical_test
     #
     #   +--------------------------------------------------------+
     #   |                         usr                            |
     #
     #   +--------------------------------------------------------+
     #   |                         usr                            |
@@ -114,7 +89,7 @@ class MailshearsTest < MiniTest::Test
     #   +---------+--------------+----------------+
     #
     #
     #   +---------+--------------+----------------+
     #
     #
-    # 3. postfixadmin_test
+    # 2. postfixadmin_test
     #
     #   +-------------+
     #   |   domain    |
     #
     #   +-------------+
     #   |   domain    |
@@ -176,7 +151,7 @@ class MailshearsTest < MiniTest::Test
     #   | admin@example.com | example.net |
     #   +-------------------+-------------+
     #
     #   | admin@example.com | example.net |
     #   +-------------------+-------------+
     #
-    # 4. roundcube_test
+    # 3. roundcube_test
     #
     #
     #   +---------+--------------------+
     #
     #
     #   +---------+--------------------+
@@ -208,24 +183,23 @@ class MailshearsTest < MiniTest::Test
       plugin_dbname = cfg.send("#{plugin}_dbname")
       next if plugin_dbname.nil? # Skip the dovecot plugin
       query = "CREATE DATABASE #{plugin_dbname};"
       plugin_dbname = cfg.send("#{plugin}_dbname")
       next if plugin_dbname.nil? # Skip the dovecot plugin
       query = "CREATE DATABASE #{plugin_dbname};"
-      connection.query(query)
+      connection.sync_exec(query)
 
 
-      plugin_dbhost = cfg.send("#{plugin}_dbhost")
-      plugin_dbport = cfg.send("#{plugin}_dbport")
-      plugin_dbopts = cfg.send("#{plugin}_dbopts")
-      plugin_dbtty  = cfg.send("#{plugin}_dbtty")
-      plugin_dbuser = cfg.send("#{plugin}_dbuser")
-      plugin_dbpass = cfg.send("#{plugin}_dbpass")
+      plugin_dbhash = {
+        :host     => cfg.send("#{plugin}_dbhost"),
+        :port     => cfg.send("#{plugin}_dbport"),
+        :options  => cfg.send("#{plugin}_dbopts"),
+        :dbname   => plugin_dbname,
+        :user     => cfg.send("#{plugin}_dbuser"),
+        :password => cfg.send("#{plugin}_dbpass")
+      }
 
 
-      plugin_conn = PG::Connection.new(plugin_dbhost, plugin_dbport,
-                                       plugin_dbopts, plugin_dbtty,
-                                       plugin_dbname, plugin_dbuser,
-                                       plugin_dbpass)
+      plugin_conn = PG::Connection.new(plugin_dbhash)
 
       sql = File.open("test/sql/#{plugin}.sql").read()
 
       sql = File.open("test/sql/#{plugin}.sql").read()
-      plugin_conn.query(sql)
+      plugin_conn.sync_exec(sql)
       sql = File.open("test/sql/#{plugin}-fixtures.sql").read()
       sql = File.open("test/sql/#{plugin}-fixtures.sql").read()
-      plugin_conn.query(sql)
+      plugin_conn.sync_exec(sql)
       plugin_conn.close()
     end
 
       plugin_conn.close()
     end
 
@@ -246,7 +220,7 @@ class MailshearsTest < MiniTest::Test
       plugin_dbname = cfg.send("#{plugin}_dbname")
       next if plugin_dbname.nil? # Skip the dovecot plugin
       query = "DROP DATABASE IF EXISTS #{plugin_dbname};"
       plugin_dbname = cfg.send("#{plugin}_dbname")
       next if plugin_dbname.nil? # Skip the dovecot plugin
       query = "DROP DATABASE IF EXISTS #{plugin_dbname};"
-      connection.query(query)
+      connection.sync_exec(query)
     end
 
     connection.close()
     end
 
     connection.close()