about summary refs log tree commit homepage
path: root/t/mda.t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2014-04-26 01:01:10 +0000
committerEric Wong <e@80x24.org>2014-04-26 01:47:51 +0000
commite022d3377fd2c50fd9931bf96394728958a90bf3 (patch)
tree0b2a4725ddb2f289893e41abe81099648253a80c /t/mda.t
parent89f34da9a510bf87293721942d688b1425bb9cf7 (diff)
downloadpublic-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.t21
1 files changed, 21 insertions, 0 deletions
diff --git a/t/mda.t b/t/mda.t
index 3357718c..fad96e5b 100644
--- a/t/mda.t
+++ b/t/mda.t
@@ -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&#233;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;