]>
| Commit | Line | Data |
|---|---|---|
| 82af6c12 MG |
1 | #!/usr/bin/perl |
| 2 | use strict; | |
| 3 | use warnings; | |
| 4 | ||
| 8dffa80b | 5 | use Test::More tests => 3; |
| 82af6c12 MG |
6 | BEGIN { use_ok('App::Lastmsg') }; |
| 7 | ||
| 82af6c12 MG |
8 | { |
| 9 | no warnings 'redefine'; | |
| 8d772799 | 10 | *App::Lastmsg::format_time = sub { shift }; |
| 82af6c12 MG |
11 | } |
| 12 | ||
| 13 | chdir 't'; | |
| 14 | my $out = ''; | |
| 15 | open my $fh, '>', \$out or die "$!"; | |
| 16 | $App::Lastmsg::OUTPUT_FILEHANDLE = $fh; | |
| 17 | $0 = 'lastmsg'; | |
| 18 | App::Lastmsg::run; | |
| 19 | ||
| 20 | is $out, <<'EOF', 'output is correct'; | |
| 636bd918 MG |
21 | user2 user2@example.org 1483182600 |
| 22 | user1 user1@example.com 1483105440 | |
| 82af6c12 MG |
23 | user3 NOT FOUND |
| 24 | EOF | |
| 8dffa80b MG |
25 | |
| 26 | $ENV{LASTMSG_DEBUG} = 1; | |
| 27 | my $err = ''; | |
| 28 | close STDERR; | |
| 29 | open STDERR, '>', \$err or die "$!"; | |
| 30 | App::Lastmsg::run; | |
| 31 | ||
| 32 | is $err, <<'EOF', 'debug output is correct'; | |
| 33 | Scanning inbox (inbox) | |
| 34 | Processing <mail1@example.com> from User 1 <user1@example.com> (Comment) | |
| 35 | Processing <mail2@example.com> from user1@example.com | |
| 36 | Processing <mail3@example.com> from user2@example.com | |
| 37 | Scanning sent (sent) | |
| 38 | Processing <33r32r32igf432g@localhost.localdomain> sent to Random User <rando@example.com> (Very random), User 2 <user2@example.org> | |
| 39 | EOF |