From: Michael Orlitzky Date: Wed, 4 Nov 2015 16:40:23 +0000 (-0500) Subject: Add an idempotence test for pruning. X-Git-Tag: 0.0.1~26 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=08c59f98a558acd7f166e5382a1b2fec5b57d68c;p=mailshears.git Add an idempotence test for pruning. --- diff --git a/doc/TODO b/doc/TODO index 5b007a9..92a90b4 100644 --- a/doc/TODO +++ b/doc/TODO @@ -15,8 +15,6 @@ * Write a man page. -* Tests: Add an idempotence test for prune. - * Tests: Check that child tables contain what they're supposed to, too. * Update the README. 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