class TestPrune < MailshearsTest
- def test_single_prune
+ def check_assertions(actual)
cfg = configuration()
- output_buffer = StringIO.new()
-
- $stdout = output_buffer
- PrunePlugin.run(cfg)
- $stdout = STDOUT
-
- actual = output_buffer.string()
-
+ # Both of our tests have the same expected output / results, so
+ # check them both using the same function.
expected =
"AgendavPrune - Removed user booger@example.com.\n" +
"DavicalPrune - Removed user booger@example.com (Principal ID: 2).\n" +
assert(!maildir_exists('example.com/jeremy'))
end
+
+ def test_single_prune()
+ # Run prune once and see what happens.
+ cfg = configuration()
+
+ output_buffer = StringIO.new()
+
+ $stdout = output_buffer
+ PrunePlugin.run(cfg)
+ $stdout = STDOUT
+
+ actual = output_buffer.string()
+
+ check_assertions(actual)
+ end
+
+
+ def test_double_prune
+ # Run prune twice. This should have the exact same output as
+ # running it once, since the second time around, there's nothing
+ # to prune.
+ cfg = configuration()
+
+ output_buffer = StringIO.new()
+
+ $stdout = output_buffer
+ PrunePlugin.run(cfg)
+ PrunePlugin.run(cfg)
+ $stdout = STDOUT
+
+ actual = output_buffer.string()
+
+ check_assertions(actual)
+ end
+
end