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