[Rt-commit] r15680 - rt/3.8/trunk/t/maildigest
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Sun Aug 31 22:12:32 EDT 2008
Author: sunnavy
Date: Sun Aug 31 22:12:32 2008
New Revision: 15680
Modified:
rt/3.8/trunk/t/maildigest/attributes.t
Log:
refactor maildigest/attributes.t a bit
Modified: rt/3.8/trunk/t/maildigest/attributes.t
==============================================================================
--- rt/3.8/trunk/t/maildigest/attributes.t (original)
+++ rt/3.8/trunk/t/maildigest/attributes.t Sun Aug 31 22:12:32 2008
@@ -136,43 +136,32 @@
# Now let's actually run the daily and weekly digest tool to make sure we generate those
# the first time get the content
-{open (my $digester, "-|", $RT::SbinPath."/rt-email-digest --mode daily --print");
-my @results = <$digester>;
-my $content = join ('', @results);
-like($content, qr/in the last day/);
-} {
+email_digest_like( '--mode daily --print', qr/in the last day/ );
# The second time run it for real so we make sure that we get RT to mark the txn as sent
-open (my $digester, "-|", $RT::SbinPath."/rt-email-digest --mode daily");
-my @results = <$digester>;
-my $content = join ('', @results);
-like($content, qr/maildaily\@/);
-close($digester);
-}
+email_digest_like( '--mode daily', qr/maildaily\@/ );
# now we should have nothing to do, so no content.
-{open (my $digester, "-|", $RT::SbinPath."/rt-email-digest --mode daily --print");
-my @results = <$digester>;
-my $content = join ('', @results);
-is ($content, '');
-}
+email_digest_like( '--mode daily --print', '' );
# the first time get the content
-{open (my $digester, "-|", $RT::SbinPath."/rt-email-digest --mode weekly --print");
-my @results = <$digester>;
-my $content = join ('', @results);
-like($content, qr/in the last seven days/);
-} {
+email_digest_like( '--mode weekly --print', qr/in the last seven days/ );
# The second time run it for real so we make sure that we get RT to mark the txn as sent
-open (my $digester, "-|", $RT::SbinPath."/rt-email-digest --mode weekly");
-my @results = <$digester>;
-my $content = join ('', @results);
-like($content, qr/mailweekly\@/);
-close($digester);
-}
+email_digest_like( '--mode weekly', qr/mailweekly\@/ );
# now we should have nothing to do, so no content.
-{open (my $digester, "-|", $RT::SbinPath."/rt-email-digest --mode weekly --print");
-my @results = <$digester>;
-my $content = join ('', @results);
-is ($content, '');
-}
+email_digest_like( '--mode weekly --print', '' );
+sub email_digest_like {
+ my $arg = shift;
+ my $pattern = shift;
+ my $perl = $^X . ' ' . join ' ', map { "-I$_" } @INC;
+ open my $digester, "-|", "$perl $RT::SbinPath/rt-email-digest $arg";
+ my @results = <$digester>;
+ my $content = join '', @results;
+ if ( ref $pattern && ref $pattern eq 'Regexp' ) {
+ like($content, $pattern);
+ }
+ else {
+ is( $content, $pattern );
+ }
+ close $digester;
+}
More information about the Rt-commit
mailing list