]> gitweb.michael.orlitzky.com - mailshears.git/commitdiff
Add a real rm test.
authorMichael Orlitzky <michael@orlitzky.com>
Sat, 4 Jan 2014 20:01:12 +0000 (15:01 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Sat, 4 Jan 2014 20:01:12 +0000 (15:01 -0500)
test/rm_account_test.rb

index e39ead56f5fec58ee581613783083352e62e9fbb..bd0ac3024fda5dd54251ced90d789bac95bfa6ba 100644 (file)
@@ -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