]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/mda.t
inboxwritable: mime_from_path: reuse in more places
[public-inbox.git] / t / mda.t
diff --git a/t/mda.t b/t/mda.t
index 631bb8613f6cb9e3aacb7f4b1de285f68efd65c3..ec09cf69bb6a6e1a229b19aed2e15f3449d781d0 100644 (file)
--- a/t/mda.t
+++ b/t/mda.t
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2019 all contributors <meta@public-inbox.org>
+# Copyright (C) 2014-2020 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use warnings;
@@ -7,6 +7,7 @@ use Email::MIME;
 use Cwd qw(getcwd);
 use PublicInbox::MID qw(mid2path);
 use PublicInbox::Git;
+use PublicInbox::InboxWritable;
 use PublicInbox::TestCommon;
 my ($tmpdir, $for_destroy) = tmpdir();
 my $home = "$tmpdir/pi-home";
@@ -34,7 +35,7 @@ my $fail_bad_header = sub ($$$) {
                "no error on undeliverable ($msg)");
        my $rev = $git->qx(qw(rev-list HEAD));
        chomp $rev;
-       is($rev, $good_rev, "bad revision not commited ($msg)");
+       is($rev, $good_rev, "bad revision not committed ($msg)");
        @f = glob("$faildir/*/*");
        is(scalar @f, 1, "faildir written to");
        [ $in, $out, $err ];
@@ -62,12 +63,9 @@ local $ENV{GIT_COMMITTER_NAME} = eval {
        use PublicInbox::MDA;
        use PublicInbox::Address;
        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::MIME->new($str);
-
+       my $eml = 't/utf8.eml';
+       my $msg = PublicInbox::InboxWritable::mime_from_path($eml) or
+               die "failed to open $eml: $!";
        my $from = $msg->header('From');
        my ($author) = PublicInbox::Address::names($from);
        my ($email) = PublicInbox::Address::emails($from);