X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=blobdiff_plain;f=test%2Frm_account_test.rb;h=bd0ac3024fda5dd54251ced90d789bac95bfa6ba;hp=b2d61749775722599707d784b33bb27b57aaa0ba;hb=25ce6f72160050d0d13531abb0158286ab093d14;hpb=0a0b9b0feb369d53af4ca7ffdd183db786f1127d diff --git a/test/rm_account_test.rb b/test/rm_account_test.rb index b2d6174..bd0ac30 100644 --- a/test/rm_account_test.rb +++ b/test/rm_account_test.rb @@ -1,5 +1,6 @@ require 'pg' require 'test/unit' + require 'common/configuration' class RmAccountTest < Test::Unit::TestCase @@ -27,8 +28,35 @@ class RmAccountTest < Test::Unit::TestCase end - def test_dummy - assert(true) + def test_single_rm + cfg = Configuration.new(TESTCONF_PATH) + argv = ["adam@example.net"] + + # Load each of the plugins that we'll need. + cfg.plugins.each do |plugin_file| + require "rm/plugins/#{plugin_file}" + end + + # And the runners. + require "rm/rm_runner" + require "rm/rm_dummy_runner" + + require 'stringio' + output_buffer = StringIO.new() + + $stdout = output_buffer + plugin_class = RmPlugin.run(cfg, *argv) + $stdout = STDOUT + + actual = output_buffer.string() + + expected = "PostfixadminRm - Removed user: " + + "adam@example.net (adam@example.net)\n" + + "RoundcubeRm - Removed user: adam@example.net (User ID: 2)\n" + + "AgendavRm - Removed user: adam@example.net " + + "(Username: adam@example.net)\n" + + "DavicalRm - User not found: adam@example.net\n" + assert(actual == expected) end def setup @@ -58,6 +86,8 @@ class RmAccountTest < Test::Unit::TestCase sql = File.open("test/sql/#{plugin}.sql").read() plugin_conn.query(sql) + sql = File.open("test/sql/#{plugin}-fixtures.sql").read() + plugin_conn.query(sql) plugin_conn.close() end