diff options
author | Eric Wong <e@80x24.org> | 2014-04-26 01:01:10 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2014-04-26 01:47:51 +0000 |
commit | e022d3377fd2c50fd9931bf96394728958a90bf3 (patch) | |
tree | 0b2a4725ddb2f289893e41abe81099648253a80c /t/mda.t | |
parent | 89f34da9a510bf87293721942d688b1425bb9cf7 (diff) | |
download | public-inbox-e022d3377fd2c50fd9931bf96394728958a90bf3.tar.gz |
Hopefully this simplifies and corrects our usage of Perl encoding APIs.
Diffstat (limited to 't/mda.t')
-rw-r--r-- | t/mda.t | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; use Email::MIME; +use Email::Filter; use File::Temp qw/tempdir/; use Cwd; use IPC::Run qw(run); @@ -43,6 +44,26 @@ my $failbox = "$home/fail.mbox"; } } +local $ENV{GIT_COMMITTER_NAME} = eval { + use PublicInbox::MDA; + use Encode qw/encode/; + my $mbox = 't/utf8.mbox'; + open(my $fh, '<', $mbox) or die "failed to open mbox: $mbox\n"; + my $str = eval { local $/; <$fh> }; + close $fh; + my $msg = Email::Filter->new(data => $str); + $msg = Email::MIME->new($msg->simple->as_string); + my ($author, $email, $date) = PublicInbox::MDA->author_info($msg); + is('Eléanor', + encode('us-ascii', my $tmp = $author, Encode::HTMLCREF), + 'HTML conversion is correct'); + is($email, 'e@example.com', 'email parsed correctly'); + is($date, 'Thu, 01 Jan 1970 00:00:00 +0000', + 'message date parsed correctly'); + $author; +}; +die $@ if $@; + { my $good_rev; local $ENV{PI_EMERGENCY} = $failbox; |