X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=blobdiff_plain;f=test%2Fmailshears_test.rb;h=8e80c063f0a3a07092996d2eab49f82d50db5d8d;hp=b4ba814f014e2dd83919f07200ac04dc1804fd18;hb=a731b98f97194b8882c42d3c2b27de75f60d6b05;hpb=371cc929cd8832f2a45ef75d7ed8db3e6ea3ed7c diff --git a/test/mailshears_test.rb b/test/mailshears_test.rb index b4ba814..8e80c06 100644 --- a/test/mailshears_test.rb +++ b/test/mailshears_test.rb @@ -32,13 +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 = PGconn.connect(db_host, db_port, db_opts, db_tty, + db_name, db_user, db_pass) return connection end @@ -183,6 +178,10 @@ class MailshearsTest < MiniTest::Unit::TestCase # | 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". @@ -207,12 +206,8 @@ 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_conn = PGconn.connect(plugin_dbhost, plugin_dbport, plugin_dbopts, + plugin_dbtty, plugin_dbname, plugin_dbuser, plugin_dbpass) sql = File.open("test/sql/#{plugin}.sql").read() @@ -231,17 +226,21 @@ class MailshearsTest < MiniTest::Unit::TestCase 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