From: Marius Gavrilescu Date: Sat, 7 Jan 2017 19:22:56 +0000 (+0200) Subject: Improve tests X-Git-Tag: 0.002~1 X-Git-Url: http://git.ieval.ro/?p=app-lastmsg.git;a=commitdiff_plain;h=8dffa80bd13da3bedacff245a20f896ee9ceb602 Improve tests --- diff --git a/lib/App/Lastmsg.pm b/lib/App/Lastmsg.pm index 07f71db..40a3e8a 100644 --- a/lib/App/Lastmsg.pm +++ b/lib/App/Lastmsg.pm @@ -65,9 +65,8 @@ sub run { my ($from) = grep { /^from$/i } $msg->header_names; $from = $msg->header_raw($from); if ($ENV{LASTMSG_DEBUG}) { - my $mid = grep { /^message-id$/i } $msg->header_names; - say STDERR 'Processing ', $msg->header_raw('Message-ID'), - " from $from" if $ENV{LASTMSG_DEBUG}; + my ($mid) = grep { /^message-id$/i } $msg->header_names; + say STDERR 'Processing ', $msg->header_raw($mid), " from $from"; } $process_message->($msg, $from); } @@ -84,9 +83,9 @@ sub run { @people = (@people, split /,/, $msg->header_raw($hdr)); } if ($ENV{LASTMSG_DEBUG}) { - my $mid = grep { /^message-id$/i } $msg->header_names; + my ($mid) = grep { /^message-id$/i } $msg->header_names; say STDERR 'Processing ', $msg->header_raw($mid), - ' sent to ', join ',', @people if $ENV{LASTMSG_DEBUG}; + ' sent to ', join ',', @people; } $process_message->($msg, @people); } diff --git a/t/App-Lastmsg.t b/t/App-Lastmsg.t index a984509..b8ad563 100644 --- a/t/App-Lastmsg.t +++ b/t/App-Lastmsg.t @@ -2,7 +2,7 @@ use strict; use warnings; -use Test::More tests => 2; +use Test::More tests => 3; BEGIN { use_ok('App::Lastmsg') }; { @@ -22,3 +22,18 @@ user2 user2@example.org 1483182600 user1 user1@example.com 1483105440 user3 NOT FOUND EOF + +$ENV{LASTMSG_DEBUG} = 1; +my $err = ''; +close STDERR; +open STDERR, '>', \$err or die "$!"; +App::Lastmsg::run; + +is $err, <<'EOF', 'debug output is correct'; +Scanning inbox (inbox) +Processing from User 1 (Comment) +Processing from user1@example.com +Processing from user2@example.com +Scanning sent (sent) +Processing <33r32r32igf432g@localhost.localdomain> sent to Random User (Very random), User 2 +EOF diff --git a/t/lastmsg.config b/t/lastmsg.config index 52f3987..b827077 100644 --- a/t/lastmsg.config +++ b/t/lastmsg.config @@ -1,5 +1,7 @@ --- -inbox: inbox +inbox: + - inbox + - does_not_exist sent: sent track: user1: user1@example.com