]> iEval git - app-lastmsg.git/commitdiff
Improve tests
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 7 Jan 2017 19:22:56 +0000 (21:22 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 7 Jan 2017 19:22:56 +0000 (21:22 +0200)
lib/App/Lastmsg.pm
t/App-Lastmsg.t
t/lastmsg.config

index 07f71db434c4789cceab6035c054527780f5f4ed..40a3e8a4b89d06c692ef0e62da9e4af92400760e 100644 (file)
@@ -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);
                }
index a9845098fc2e2632775d2d4e4251917ba8a20034..b8ad563ee4567a01f8ecae202df600e7fe30468a 100644 (file)
@@ -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 <mail1@example.com> from User 1 <user1@example.com> (Comment)
+Processing <mail2@example.com> from user1@example.com
+Processing <mail3@example.com> from user2@example.com
+Scanning sent (sent)
+Processing <33r32r32igf432g@localhost.localdomain> sent to Random User <rando@example.com> (Very random), User 2 <user2@example.org>
+EOF
index 52f3987034c7fb41feb276ca9362f796e1bd508b..b827077d2cb8c0a4ef2a8f3ae5136afb0587d76c 100644 (file)
@@ -1,5 +1,7 @@
 ---
-inbox: inbox
+inbox:
+ - inbox
+ - does_not_exist
 sent: sent
 track:
   user1: user1@example.com
This page took 0.032619 seconds and 4 git commands to generate.