unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@yhbt.net>
To: meta@public-inbox.org
Subject: [PATCH 2/4] t/*.t: use Email::MIME->create over PublicInbox::MIME->create
Date: Tue, 21 Apr 2020 21:16:12 +0000	[thread overview]
Message-ID: <20200421211614.5076-3-e@yhbt.net> (raw)
In-Reply-To: <20200421211614.5076-1-e@yhbt.net>

PublicInbox::MIME only supports ->new, and is only different
from Email::MIME for old versions of Email::MIME.  In the
future, PublicInbox::MIME may not be a subclass of Email::MIME
at all.
---
 t/convert-compact.t    | 4 ++--
 t/import.t             | 3 ++-
 t/indexlevels-mirror.t | 4 ++--
 t/msgtime.t            | 5 +++--
 t/psgi_v2.t            | 8 ++++----
 t/time.t               | 4 ++--
 t/v1-add-remove-add.t  | 5 ++---
 t/v1reindex.t          | 5 ++---
 t/v2-add-remove-add.t  | 5 ++---
 t/v2mda.t              | 5 ++---
 t/v2reindex.t          | 4 ++--
 t/v2writable.t         | 4 ++--
 t/xcpdb-reshard.t      | 4 ++--
 13 files changed, 29 insertions(+), 31 deletions(-)

diff --git a/t/convert-compact.t b/t/convert-compact.t
index af16b701..376e0f6a 100644
--- a/t/convert-compact.t
+++ b/t/convert-compact.t
@@ -7,7 +7,7 @@ use PublicInbox::MIME;
 use PublicInbox::Spawn qw(which);
 use PublicInbox::TestCommon;
 require_git(2.6);
-require_mods(qw(DBD::SQLite Search::Xapian));
+require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
 which('xapian-compact') or
 	plan skip_all => 'xapian-compact missing for '.__FILE__;
 
@@ -26,7 +26,7 @@ ok(PublicInbox::Import::run_die([qw(git) , "--git-dir=$ibx->{inboxdir}",
 	qw(config core.sharedRepository 0644)]), 'set sharedRepository');
 $ibx = PublicInbox::Inbox->new($ibx);
 my $im = PublicInbox::Import->new($ibx->git, undef, undef, $ibx);
-my $mime = PublicInbox::MIME->create(
+my $mime = Email::MIME->create(
 	header => [
 		From => 'a@example.com',
 		To => 'test@example.com',
diff --git a/t/import.t b/t/import.t
index 79af9846..53345b12 100644
--- a/t/import.t
+++ b/t/import.t
@@ -10,12 +10,13 @@ use PublicInbox::Spawn qw(spawn);
 use Fcntl qw(:DEFAULT SEEK_SET);
 use File::Temp qw/tempfile/;
 use PublicInbox::TestCommon;
+require_mods(qw(Email::MIME));
 my ($dir, $for_destroy) = tmpdir();
 
 my $git = PublicInbox::Git->new($dir);
 my $im = PublicInbox::Import->new($git, 'testbox', 'test@example');
 $im->init_bare;
-my $mime = PublicInbox::MIME->create(
+my $mime = Email::MIME->create(
 	header => [
 		From => 'a@example.com',
 		To => 'b@example.com',
diff --git a/t/indexlevels-mirror.t b/t/indexlevels-mirror.t
index f2200306..90506e28 100644
--- a/t/indexlevels-mirror.t
+++ b/t/indexlevels-mirror.t
@@ -10,9 +10,9 @@ require PublicInbox::Admin;
 use PublicInbox::TestCommon;
 my $PI_TEST_VERSION = $ENV{PI_TEST_VERSION} || 2;
 require_git('2.6') if $PI_TEST_VERSION == 2;
-require_mods(qw(DBD::SQLite));
+require_mods(qw(DBD::SQLite Email::MIME));
 
-my $mime = PublicInbox::MIME->create(
+my $mime = Email::MIME->create(
 	header => [
 		From => 'a@example.com',
 		To => 'test@example.com',
diff --git a/t/msgtime.t b/t/msgtime.t
index 3f09fb4e..058f3886 100644
--- a/t/msgtime.t
+++ b/t/msgtime.t
@@ -6,12 +6,13 @@ use Test::More;
 use PublicInbox::MIME;
 use PublicInbox::MsgTime;
 use PublicInbox::TestCommon;
+require_mods(qw(Email::MIME));
 
 our $received_date = 'Mon, 22 Jan 2007 13:16:24 -0500';
 sub datestamp ($) {
 	my ($date) = @_;
 	local $SIG{__WARN__} = sub {};  # Suppress warnings
-	my $mime = PublicInbox::MIME->create(
+	my $mime = Email::MIME->create(
 		header => [
 			From => 'a@example.com',
 			To => 'b@example.com',
@@ -34,7 +35,7 @@ EOF
 sub timestamp ($) {
 	my ($received) = @_;
 	local $SIG{__WARN__} = sub {};  # Suppress warnings
-	my $mime = PublicInbox::MIME->create(
+	my $mime = Email::MIME->create(
 		header => [
 			From => 'a@example.com',
 			To => 'b@example.com',
diff --git a/t/psgi_v2.t b/t/psgi_v2.t
index 57017de1..bc26a112 100644
--- a/t/psgi_v2.t
+++ b/t/psgi_v2.t
@@ -9,7 +9,7 @@ use PublicInbox::MIME;
 use PublicInbox::Config;
 use PublicInbox::MID qw(mids);
 require_mods(qw(DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test
-		URI::Escape Plack::Builder));
+		URI::Escape Plack::Builder Email::MIME));
 use_ok($_) for (qw(HTTP::Request::Common Plack::Test));
 use_ok 'PublicInbox::WWW';
 use_ok 'PublicInbox::V2Writable';
@@ -226,11 +226,11 @@ test_psgi(sub { $www->call(@_) }, sub {
 	# ensure conflicted attachments can be resolved
 	foreach my $body (qw(old new)) {
 		my $parts = [
-			PublicInbox::MIME->create(
+			Email::MIME->create(
 				attributes => { content_type => 'text/plain' },
 				body => 'blah',
 			),
-			PublicInbox::MIME->create(
+			Email::MIME->create(
 				attributes => {
 					filename => 'attach.txt',
 					content_type => 'text/plain',
@@ -238,7 +238,7 @@ test_psgi(sub { $www->call(@_) }, sub {
 				body => $body
 			)
 		];
-		$mime = PublicInbox::MIME->create(
+		$mime = Email::MIME->create(
 			parts => $parts,
 			header_str => [ From => 'root@z',
 				'Message-ID' => '<a@dup>',
diff --git a/t/time.t b/t/time.t
index 3cba3bd1..94bf9181 100644
--- a/t/time.t
+++ b/t/time.t
@@ -3,9 +3,9 @@
 use strict;
 use warnings;
 use Test::More;
-use_ok 'PublicInbox::MIME';
+use_ok 'Email::MIME';
 use PublicInbox::MsgTime qw(msg_datestamp);
-my $mime = PublicInbox::MIME->create(
+my $mime = Email::MIME->create(
 	header => [
 		From => 'a@example.com',
 		To => 'test@example.com',
diff --git a/t/v1-add-remove-add.t b/t/v1-add-remove-add.t
index fdf06a96..c3a7e77f 100644
--- a/t/v1-add-remove-add.t
+++ b/t/v1-add-remove-add.t
@@ -3,10 +3,9 @@
 use strict;
 use warnings;
 use Test::More;
-use PublicInbox::MIME;
 use PublicInbox::Import;
 use PublicInbox::TestCommon;
-require_mods(qw(DBD::SQLite Search::Xapian));
+require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
 require PublicInbox::SearchIdx;
 my ($inboxdir, $for_destroy) = tmpdir();
 my $ibx = {
@@ -15,7 +14,7 @@ my $ibx = {
 	-primary_address => 'test@example.com',
 };
 $ibx = PublicInbox::Inbox->new($ibx);
-my $mime = PublicInbox::MIME->create(
+my $mime = Email::MIME->create(
 	header => [
 		From => 'a@example.com',
 		To => 'test@example.com',
diff --git a/t/v1reindex.t b/t/v1reindex.t
index 378c8efb..ce3833be 100644
--- a/t/v1reindex.t
+++ b/t/v1reindex.t
@@ -3,12 +3,11 @@
 use strict;
 use warnings;
 use Test::More;
-use PublicInbox::MIME;
 use PublicInbox::ContentId qw(content_digest);
 use File::Path qw(remove_tree);
 use PublicInbox::TestCommon;
 require_git(2.6);
-require_mods(qw(DBD::SQLite Search::Xapian));
+require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
 use_ok 'PublicInbox::SearchIdx';
 use_ok 'PublicInbox::Import';
 my ($inboxdir, $for_destroy) = tmpdir();
@@ -18,7 +17,7 @@ my $ibx_config = {
 	-primary_address => 'test@example.com',
 	indexlevel => 'full',
 };
-my $mime = PublicInbox::MIME->create(
+my $mime = Email::MIME->create(
 	header => [
 		From => 'a@example.com',
 		To => 'test@example.com',
diff --git a/t/v2-add-remove-add.t b/t/v2-add-remove-add.t
index 328f5326..ca998334 100644
--- a/t/v2-add-remove-add.t
+++ b/t/v2-add-remove-add.t
@@ -3,10 +3,9 @@
 use strict;
 use warnings;
 use Test::More;
-use PublicInbox::MIME;
 use PublicInbox::TestCommon;
 require_git(2.6);
-require_mods(qw(DBD::SQLite Search::Xapian));
+require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
 use_ok 'PublicInbox::V2Writable';
 my ($inboxdir, $for_destroy) = tmpdir();
 my $ibx = {
@@ -16,7 +15,7 @@ my $ibx = {
 	-primary_address => 'test@example.com',
 };
 $ibx = PublicInbox::Inbox->new($ibx);
-my $mime = PublicInbox::MIME->create(
+my $mime = Email::MIME->create(
 	header => [
 		From => 'a@example.com',
 		To => 'test@example.com',
diff --git a/t/v2mda.t b/t/v2mda.t
index e9dcdf44..94b63310 100644
--- a/t/v2mda.t
+++ b/t/v2mda.t
@@ -3,14 +3,13 @@
 use strict;
 use warnings;
 use Test::More;
-use PublicInbox::MIME;
 use Fcntl qw(SEEK_SET);
 use Cwd;
 use PublicInbox::TestCommon;
 require_git(2.6);
 
 my $V = 2;
-require_mods(qw(DBD::SQLite Search::Xapian));
+require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
 use_ok 'PublicInbox::V2Writable';
 my ($tmpdir, $for_destroy) = tmpdir();
 my $ibx = {
@@ -18,7 +17,7 @@ my $ibx = {
 	name => 'test-v2writable',
 	address => [ 'test@example.com' ],
 };
-my $mime = PublicInbox::MIME->create(
+my $mime = Email::MIME->create(
 	header => [
 		From => 'a@example.com',
 		To => 'test@example.com',
diff --git a/t/v2reindex.t b/t/v2reindex.t
index b6164ff8..7bf6bc2f 100644
--- a/t/v2reindex.t
+++ b/t/v2reindex.t
@@ -8,7 +8,7 @@ use PublicInbox::ContentId qw(content_digest);
 use File::Path qw(remove_tree);
 use PublicInbox::TestCommon;
 require_git(2.6);
-require_mods(qw(DBD::SQLite Search::Xapian));
+require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
 use_ok 'PublicInbox::V2Writable';
 my ($inboxdir, $for_destroy) = tmpdir();
 my $ibx_config = {
@@ -24,7 +24,7 @@ my $agpl = do {
 	<$fh>;
 };
 my $phrase = q("defending all users' freedom");
-my $mime = PublicInbox::MIME->create(
+my $mime = Email::MIME->create(
 	header => [
 		From => 'a@example.com',
 		To => 'test@example.com',
diff --git a/t/v2writable.t b/t/v2writable.t
index 8897062a..7e7560b3 100644
--- a/t/v2writable.t
+++ b/t/v2writable.t
@@ -8,7 +8,7 @@ use PublicInbox::ContentId qw(content_digest content_id);
 use PublicInbox::TestCommon;
 use Cwd qw(abs_path);
 require_git(2.6);
-require_mods(qw(DBD::SQLite Search::Xapian));
+require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
 local $ENV{HOME} = abs_path('t');
 use_ok 'PublicInbox::V2Writable';
 umask 007;
@@ -20,7 +20,7 @@ my $ibx = {
 	-primary_address => 'test@example.com',
 };
 $ibx = PublicInbox::Inbox->new($ibx);
-my $mime = PublicInbox::MIME->create(
+my $mime = Email::MIME->create(
 	header => [
 		From => 'a@example.com',
 		To => 'test@example.com',
diff --git a/t/xcpdb-reshard.t b/t/xcpdb-reshard.t
index 58932fc2..2571329e 100644
--- a/t/xcpdb-reshard.t
+++ b/t/xcpdb-reshard.t
@@ -4,13 +4,13 @@ use strict;
 use warnings;
 use Test::More;
 use PublicInbox::TestCommon;
-require_mods(qw(DBD::SQLite Search::Xapian));
+require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
 require_git('2.6');
 use PublicInbox::MIME;
 use PublicInbox::InboxWritable;
 require PublicInbox::Search;
 
-my $mime = PublicInbox::MIME->create(
+my $mime = Email::MIME->create(
 	header => [
 		From => 'a@example.com',
 		To => 'test@example.com',

  parent reply	other threads:[~2020-04-21 21:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21 21:16 [PATCH 0/4] some test cleanups Eric Wong
2020-04-21 21:16 ` [PATCH 1/4] t/feed: remove useless $ENV{GIT_DIR} assignment Eric Wong
2020-04-21 21:16 ` Eric Wong [this message]
2020-04-21 21:16 ` [PATCH 3/4] t/*.t: reduce dependency on Email::MIME APIs Eric Wong
2020-04-21 21:16 ` [PATCH 4/4] t/mda.t: avoid needless use of Email::Simple 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: https://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=20200421211614.5076-3-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.
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).