user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@yhbt.net>
To: meta@public-inbox.org
Subject: [PATCH 3/3] tests: replace mime_from_path with mime_load
Date: Sat, 25 Apr 2020 05:52:23 +0000	[thread overview]
Message-ID: <20200425055223.21879-4-e@yhbt.net> (raw)
In-Reply-To: <20200425055223.21879-1-e@yhbt.net>

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        | 4 +---
 t/msg_iter.t   | 9 ++-------
 t/nntpd-tls.t  | 4 +---
 t/search.t     | 4 +---
 t/solver_git.t | 4 +---
 5 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/t/mda.t b/t/mda.t
index 863eaf8f..03cc4bc3 100644
--- 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);
diff --git a/t/msg_iter.t b/t/msg_iter.t
index 6adbf165..5c57e043 100644
--- a/t/msg_iter.t
+++ b/t/msg_iter.t
@@ -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]};
diff --git a/t/nntpd-tls.t b/t/nntpd-tls.t
index a0522e1f..0ad29be0 100644
--- a/t/nntpd-tls.t
+++ b/t/nntpd-tls.t
@@ -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) {
diff --git a/t/search.t b/t/search.t
index 40264345..83986837 100644
--- a/t/search.t
+++ b/t/search.t
@@ -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];
diff --git a/t/solver_git.t b/t/solver_git.t
index 7f79ff4c..c483aba1 100644
--- a/t/solver_git.t
+++ b/t/solver_git.t
@@ -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;
 };
 

  parent reply	other threads:[~2020-04-25  5:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-25  5:52 [PATCH 0/3] remove Email::MIME->create use Eric Wong
2020-04-25  5:52 ` [PATCH 1/3] testcommon: introduce mime_load sub Eric Wong
2020-04-25  5:52 ` [PATCH 2/3] tests: remove Email::MIME->create use entirely Eric Wong
2020-04-25  5:52 ` Eric Wong [this message]
2020-04-26  7:35 ` [PATCH 4/3] testcommon: mime_load: drop extra $cb arg Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200425055223.21879-4-e@yhbt.net \
    --to=e@yhbt.net \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).