Commit | Line | Data |
d5217b4d |
1 | use strict; |
2 | use warnings FATAL => 'all'; |
3 | use IO::Pipeline; |
4 | use Test::More qw(no_plan); |
5 | |
6 | my $source = <<'END'; |
7 | 2010-03-21 16:15:30 1NtNoI-000658-6V Completed |
8 | 2010-03-21 16:17:29 1NtNlx-00062B-0R Completed |
9 | 2010-03-21 16:20:37 1NtNtF-0006AE-G6 Completed |
10 | 2010-03-21 16:28:37 no host name found for IP address 218.108.42.254 |
11 | 2010-03-21 16:28:51 H=(ZTZUWWCRQY) [218.108.42.254] F=<pansiesyd75@setupper.com> rejected RCPT <inline@trout.me.uk>: rejected because 218.108.42.254 is in a black list at zen.spamhaus.org |
12 | 2010-03-21 16:28:51 unexpected disconnection while reading SMTP command from (ZTZUWWCRQY) [218.108.42.254] (error: Connection reset by peer) |
13 | 2010-03-21 16:35:57 no host name found for IP address 123.122.231.66 |
14 | 2010-03-21 16:35:59 H=(LFMTSDM) [123.122.231.66] F=<belladonnai6@buybuildanichestore.com> rejected RCPT <tal@fyrestorm.co.uk>: rejected because 123.122.231.66 is in a black list at zen.spamhaus.org |
15 | END |
16 | |
17 | sub input_fh { |
18 | open my $in, '<', \$source; |
19 | return $in; |
20 | } |
21 | |
22 | my $out; |
23 | |
24 | my $pipe = input_fh |
25 | | pmap { [ /^(\S+) (\S+) (.*)$/ ] } |
26 | | pgrep { $_->[2] =~ /rejected|Completed/ } |
27 | | pmap { [ @{$_}[0, 1], $_->[2] =~ /rejected/ ? 'Rejected' : 'Completed' ] } |
28 | | pmap { join(' ', @$_)."\n" } |
29 | | psink { $out .= $_ }; |
30 | |
31 | is($out, <<'END', 'Output ok'); |
32 | 2010-03-21 16:15:30 Completed |
33 | 2010-03-21 16:17:29 Completed |
34 | 2010-03-21 16:20:37 Completed |
35 | 2010-03-21 16:28:51 Rejected |
36 | 2010-03-21 16:35:59 Rejected |
37 | END |