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
# +-------------------+-------------+------------+
#
#
- # +------------------------------------------------------+
- # | alias |
- # +-------------------+-------------------+--------------+
- # | address | goto | domain |
- # +-------------------+-------------------+--------------+
- # | alice@example.com | alice@example.com | example.com |
- # +-------------------+-------------------+--------------+
- # | bob@example.com | bob@example.com | example.com |
- # +-------------------+-------------------+--------------+
- # | adam@example.net | adam@example.net | example.net |
- # +-------------------+-------------------+--------------+
- # | beth@example.net | beth@example.net | example.net |
- # +-------------------+-------------------+--------------+
- # | carol@example.net | carol@example.net | example.net |
- # +-------------------+-------------------+--------------+
+ # +-------------------------------------------------------+
+ # | alias |
+ # +-------------------+--------------------+--------------+
+ # | address | goto | domain |
+ # +-------------------+--------------------+--------------+
+ # | alice@example.com | alice@example.com, | example.com |
+ # | | adam@example.net, | |
+ # | | bob@example.com, | |
+ # | | carol@example.net | |
+ # +-------------------+--------------------+--------------+
+ # | bob@example.com | bob@example.com | example.com |
+ # +-------------------+--------------------+--------------+
+ # | adam@example.net | adam@example.net | example.net |
+ # +-------------------+--------------------+--------------+
+ # | beth@example.net | beth@example.net | example.net |
+ # +-------------------+--------------------+--------------+
+ # | carol@example.net | carol@example.net | example.net |
+ # +-------------------+--------------------+--------------+
#
#
# +---------------------------------+
# | 3 | adam@example.net |
# +---------+--------------------+
+ # First make sure we get rid of everything so we don't get random
+ # failures from databases and directories that already exist.
+ teardown()
+
cfg = configuration()
# First create the "mail directories".
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)
cfg = configuration()
connection = connect_superuser()
+ # Don't emit notices about missing tables. Why this happens when I
+ # explicitly say IF EXISTS is beyond me.
+ connection.set_notice_processor{}
+
cfg.plugins.each do |plugin|
plugin_dbname = cfg.send("#{plugin}_dbname")
next if plugin_dbname.nil? # Skip the dovecot plugin
- query = "DROP DATABASE #{plugin_dbname};"
+ query = "DROP DATABASE IF EXISTS #{plugin_dbname};"
connection.query(query)
end
connection.close()
# Get rid of the maildirs.
- FileUtils.rm_r(cfg.dovecot_mail_root())
+ FileUtils.rm_rf(cfg.dovecot_mail_root())
end
end