X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=blobdiff_plain;f=test%2Ftest_prune.rb;h=a0e69417e0f633cf1eeba599ff4d31fd39ec5a36;hp=94b819622d69f4cb4aeb6b45f4c03b7a0f21b59f;hb=08c59f98a558acd7f166e5382a1b2fec5b57d68c;hpb=50f7c817b5954a804ccc77a39f46602505b9196a diff --git a/test/test_prune.rb b/test/test_prune.rb index 94b8196..a0e6941 100644 --- a/test/test_prune.rb +++ b/test/test_prune.rb @@ -14,17 +14,11 @@ require 'prune/prune_runner' 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" + @@ -86,4 +80,39 @@ class TestPrune < MailshearsTest 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