]> Sergey Matveev's repositories - public-inbox.git/commitdiff
tests: replace mime_from_path with mime_load
authorEric Wong <e@yhbt.net>
Sat, 25 Apr 2020 05:52:23 +0000 (05:52 +0000)
committerEric Wong <e@yhbt.net>
Sun, 26 Apr 2020 07:03:15 +0000 (07:03 +0000)
mime_from_path is designed to fail gracefully in busy Maildirs
whereas mime_load was made for loading files from a work tree.

t/mda.t
t/msg_iter.t
t/nntpd-tls.t
t/search.t
t/solver_git.t

diff --git a/t/mda.t b/t/mda.t
index 863eaf8fe2dda3d3316b84ddb3737b379efebcce..03cc4bc3c444cbd0531b524c553f3f4d05be98e5 100644 (file)
--- a/t/mda.t
+++ b/t/mda.t
@@ -62,9 +62,7 @@ local $ENV{GIT_COMMITTER_NAME} = eval {
        use PublicInbox::MDA;
        use PublicInbox::Address;
        use Encode qw/encode/;
-       my $eml = 't/utf8.eml';
-       my $msg = PublicInbox::InboxWritable::mime_from_path($eml) or
-               die "failed to open $eml: $!";
+       my $msg = mime_load 't/utf8.eml';
        my $from = $msg->header('From');
        my ($author) = PublicInbox::Address::names($from);
        my ($email) = PublicInbox::Address::emails($from);
index 6adbf165b0713268cfb87bf73c9b7b9d7c45d1a9..5c57e043d05f3f9fbf1777e83646d2df7a519656 100644 (file)
@@ -5,7 +5,6 @@ use warnings;
 use Test::More;
 use PublicInbox::TestCommon;
 use PublicInbox::Hval qw(ascii_html);
-use PublicInbox::InboxWritable;
 use_ok('PublicInbox::MsgIter');
 
 {
@@ -34,9 +33,7 @@ use_ok('PublicInbox::MsgIter');
 }
 
 {
-       my $f = 't/iso-2202-jp.eml';
-       my $mime = PublicInbox::InboxWritable::mime_from_path($f) or
-               die "open $f: $!";
+       my $mime = mime_load 't/iso-2202-jp.eml';
        my $raw = '';
        msg_iter($mime, sub {
                my ($part, $level, @ex) = @{$_[0]};
@@ -49,9 +46,7 @@ use_ok('PublicInbox::MsgIter');
 }
 
 {
-       my $f = 't/x-unknown-alpine.eml';
-       my $mime = PublicInbox::InboxWritable::mime_from_path($f) or
-               die "open $f: $!";
+       my $mime = mime_load 't/x-unknown-alpine.eml';
        my $raw = '';
        msg_iter($mime, sub {
                my ($part, $level, @ex) = @{$_[0]};
index a0522e1f64d9da0ef916d90d899d3b50a177c1cf..0ad29be0b82ea4c3e4826c83001533a7d527b271 100644 (file)
@@ -63,9 +63,7 @@ EOF
 
 {
        my $im = $ibx->importer(0);
-       my $eml = 't/data/0001.patch';
-       my $mime = PublicInbox::InboxWritable::mime_from_path($eml) or
-               die "open $eml: $!";
+       my $mime = mime_load 't/data/0001.patch';
        ok($im->add($mime), 'message added');
        $im->done;
        if ($version == 1) {
index 40264345985477bc0609381d5dbdd4c606c317ac..83986837eaf9190e8c98aa21115dfeb2db19c38a 100644 (file)
@@ -286,9 +286,7 @@ EOF
 });
 
 $ibx->with_umask(sub {
-       my $eml = 't/utf8.eml';
-       my $mime = PublicInbox::InboxWritable::mime_from_path($eml) or
-               die "open $eml: $!";
+       my $mime = mime_load 't/utf8.eml';
        my $doc_id = $rw->add_message($mime);
        ok($doc_id > 0, 'message indexed doc_id with UTF-8');
        my $msg = $rw->query('m:testmessage@example.com', {limit => 1})->[0];
index 7f79ff4cc8790d65bb9052fe8880a2f44504a215..c483aba176a1fdd7b398cbe0eeb173a4d41129cd 100644 (file)
@@ -29,9 +29,7 @@ my $im = PublicInbox::V2Writable->new($ibx, 1);
 $im->{parallel} = 0;
 
 my $deliver_patch = sub ($) {
-       my $mime = PublicInbox::InboxWritable::mime_from_path($_[0]) or
-               die "open $_[0]: $!";
-       $im->add($mime);
+       $im->add(mime_load($_[0]));
        $im->done;
 };