]> Sergey Matveev's repositories - public-inbox.git/commitdiff
t/*.t: reduce dependency on Email::MIME APIs
authorEric Wong <e@yhbt.net>
Tue, 21 Apr 2020 21:16:13 +0000 (21:16 +0000)
committerEric Wong <e@yhbt.net>
Wed, 22 Apr 2020 18:26:01 +0000 (18:26 +0000)
Instead, favor PublicInbox::MIME->new for non-attachment emails.
We may support alternatives to Email::MIME down the line.

We'll still keep Email::MIME->create to deal with attachments,
for now, but there's also a fair amount of test duplication
we should eliminate, later.

37 files changed:
t/altid.t
t/altid_v2.t
t/cgi.t
t/content_id.t
t/convert-compact.t
t/feed.t
t/filter_rubylang.t
t/filter_subjecttag.t
t/filter_vger.t
t/html_index.t
t/httpd.t
t/import.t
t/indexlevels-mirror.t
t/mid.t
t/msgtime.t
t/nntp.t
t/nntpd.t
t/nulsubject.t
t/plack.t
t/psgi_attach.t
t/psgi_mount.t
t/psgi_multipart_not.t
t/psgi_scan_all.t
t/psgi_search.t
t/psgi_text.t
t/reply.t
t/search-thr-index.t
t/search.t
t/time.t
t/v1-add-remove-add.t
t/v1reindex.t
t/v2-add-remove-add.t
t/v2mda.t
t/v2reindex.t
t/v2writable.t
t/watch_maildir.t
t/xcpdb-reshard.t

index 3134e6276b54fea21cd943c7210e03e482ae2118..c7a3601a6b196f03f5111c11f89bb0b8e57f1528 100644 (file)
--- a/t/altid.t
+++ b/t/altid.t
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use PublicInbox::TestCommon;
+use PublicInbox::MIME;
 require_mods(qw(DBD::SQLite Search::Xapian));
 use_ok 'PublicInbox::Msgmap';
 use_ok 'PublicInbox::SearchIdx';
@@ -26,16 +27,14 @@ my $ibx;
        my $git = PublicInbox::Git->new($git_dir);
        my $im = PublicInbox::Import->new($git, 'testbox', 'test@example');
        $im->init_bare;
-       $im->add(Email::MIME->create(
-               header => [
-                       From => 'a@example.com',
-                       To => 'b@example.com',
-                       'Content-Type' => 'text/plain',
-                       Subject => 'boo!',
-                       'Message-ID' => '<a@example.com>',
-               ],
-               body => "hello world gmane:666\n",
-       ));
+       $im->add(PublicInbox::MIME->new(<<'EOF'));
+From: a@example.com
+To: b@example.com
+Subject: boo!
+Message-ID: <a@example.com>
+
+hello world gmane:666
+EOF
        $im->done;
 }
 {
index f31061c2f8c94cc35747218a89a5afe65134b52c..3ac294f05b3b005f9e2683b165d4daeb2d4db376 100644 (file)
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
+use PublicInbox::MIME;
 use PublicInbox::TestCommon;
 require_git(2.6);
 require_mods(qw(DBD::SQLite Search::Xapian));
@@ -30,16 +31,14 @@ my $ibx = {
 };
 $ibx = PublicInbox::Inbox->new($ibx);
 my $v2w = PublicInbox::V2Writable->new($ibx, 1);
-$v2w->add(Email::MIME->create(
-               header => [
-                       From => 'a@example.com',
-                       To => 'b@example.com',
-                       'Content-Type' => 'text/plain',
-                       Subject => 'boo!',
-                       'Message-ID' => '<a@example.com>',
-               ],
-               body => "hello world gmane:666\n",
-       ));
+$v2w->add(PublicInbox::MIME->new(<<'EOF'));
+From: a@example.com
+To: b@example.com
+Subject: boo!
+Message-ID: <a@example.com>
+
+hello world gmane:666
+EOF
 $v2w->done;
 
 my $msgs = $ibx->search->reopen->query("gmane:1234");
diff --git a/t/cgi.t b/t/cgi.t
index bceb83e57de42608c7e3ad9400afc512af03cbec..42a343d3040f06303fb42a09cce5c22f6b07f65a 100644 (file)
--- a/t/cgi.t
+++ b/t/cgi.t
@@ -5,7 +5,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::TestCommon;
 use PublicInbox::Import;
 require_mods(qw(Plack::Handler::CGI Plack::Util));
@@ -45,7 +45,7 @@ my $im = PublicInbox::InboxWritable->new($ibx)->importer;
        local $ENV{HOME} = $home;
 
        # inject some messages:
-       my $mime = Email::MIME->new(<<EOF);
+       my $mime = PublicInbox::MIME->new(<<EOF);
 From: Me <me\@example.com>
 To: You <you\@example.com>
 Cc: $addr
@@ -62,7 +62,7 @@ EOF
        ok($im->add($mime), 'added big message');
 
        # deliver a reply, too
-       $mime = Email::MIME->new(<<EOF);
+       $mime = PublicInbox::MIME->new(<<EOF);
 From: You <you\@example.com>
 To: Me <me\@example.com>
 Cc: $addr
@@ -79,7 +79,7 @@ EOF
        ok($im->add($mime), 'added reply');
 
        my $slashy_mid = 'slashy/asdf@example.com';
-       my $slashy = Email::MIME->new(<<EOF);
+       my $slashy = PublicInbox::MIME->new(<<EOF);
 From: You <you\@example.com>
 To: Me <me\@example.com>
 Cc: $addr
index 3fe44b95c6fd9bc1b4b28a1616138de580e279f9..0325164df77de292075b2ec8c885e5642cf8a1b8 100644 (file)
@@ -4,22 +4,20 @@ use strict;
 use warnings;
 use Test::More;
 use PublicInbox::ContentId qw(content_id);
-use Email::MIME;
+use PublicInbox::MIME;
 
-my $mime = Email::MIME->create(
-       header => [
-               From => 'a@example.com',
-               To => 'b@example.com',
-               'Content-Type' => 'text/plain',
-               Subject => 'this is a subject',
-               'Message-ID' => '<a@example.com>',
-               Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-       ],
-       body => "hello world\n",
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: b@example.com
+Subject: this is a subject
+Message-ID: <a@example.com>
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+
+hello world
+EOF
 
 my $orig = content_id($mime);
-my $reload = content_id(Email::MIME->new($mime->as_string));
+my $reload = content_id(PublicInbox::MIME->new($mime->as_string));
 is($orig, $reload, 'content_id matches after serialization');
 
 foreach my $h (qw(From To Cc)) {
index 376e0f6a8b15709bd15e9411e5660695f5377d0b..ae29902123c6f12ca8e6bf8c01cabfafe5b11f10 100644 (file)
@@ -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 Email::MIME));
+require_mods(qw(DBD::SQLite Search::Xapian));
 which('xapian-compact') or
        plan skip_all => 'xapian-compact missing for '.__FILE__;
 
@@ -26,16 +26,16 @@ 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 = Email::MIME->create(
-       header => [
-               From => 'a@example.com',
-               To => 'test@example.com',
-               Subject => 'this is a subject',
-               'Message-ID' => '<a-mid@b>',
-               Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-       ],
-       body => "hello world\n",
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: b@example.com
+Subject: this is a subject
+Message-ID: <a-mid@b>
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+
+hello world
+EOF
+
 ok($im->add($mime), 'added one message');
 ok($im->remove($mime), 'remove message');
 ok($im->add($mime), 'added message again');
index 7d01e3e6524c50c491690bc100e460c9abc3de18..373a1de825a72f647f4d25d818e6a58dfb0427db 100644 (file)
--- a/t/feed.t
+++ b/t/feed.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::Feed;
 use PublicInbox::Import;
 use PublicInbox::Inbox;
@@ -36,7 +36,7 @@ my $im = PublicInbox::Import->new($git, $ibx->{name}, 'test@example');
 {
        $im->init_bare;
        foreach my $i (1..6) {
-               my $mime = Email::MIME->new(<<EOF);
+               my $mime = PublicInbox::MIME->new(<<EOF);
 From: ME <me\@example.com>
 To: U <u\@example.com>
 Message-Id: <$i\@example.com>
@@ -95,7 +95,7 @@ EOF
        # add a new spam message
        my $spam;
        {
-               $spam = Email::MIME->new(<<EOF);
+               $spam = PublicInbox::MIME->new(<<EOF);
 From: SPAMMER <spammer\@example.com>
 To: U <u\@example.com>
 Message-Id: <this-is-spam\@example.com>
index 8215b6f109e8323728cfa2f897ed5dd35f39f477..05e1b324da5742caf35d58d622c9444b2bdc46b7 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::TestCommon;
 use_ok 'PublicInbox::Filter::RubyLang';
 
@@ -17,7 +17,7 @@ keep this
 Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
 <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
 EOF
-my $mime = Email::MIME->new($msg);
+my $mime = PublicInbox::MIME->new($msg);
 my $ret = $f->delivery($mime);
 is($ret, $mime, "delivery successful");
 is($mime->body, "keep this\n", 'normal message filtered OK');
@@ -41,7 +41,7 @@ X-Mail-Count: 12
 Message-ID: <a@b>
 
 EOF
-       $mime = Email::MIME->new($msg);
+       $mime = PublicInbox::MIME->new($msg);
        $ret = $f->delivery($mime);
        is($ret, $mime, "delivery successful");
        my $mm = PublicInbox::Msgmap->new($git_dir);
@@ -53,7 +53,7 @@ Message-ID: <b@b>
 
 EOF
 
-       $mime = Email::MIME->new($msg);
+       $mime = PublicInbox::MIME->new($msg);
        $ret = $f->delivery($mime);
        is($ret, 100, "delivery rejected without X-Mail-Count");
 }
index 922499d59267aba5753a0122ca5f007a2ea9f128..9b397b8c2466e8fd44c04ebdbbff1b0fa5ae8b4f 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use_ok 'PublicInbox::Filter::SubjectTag';
 
 my $f = eval { PublicInbox::Filter::SubjectTag->new };
@@ -11,7 +11,7 @@ like($@, qr/tag not defined/, 'error without args');
 $f = PublicInbox::Filter::SubjectTag->new('-tag', '[foo]');
 is(ref $f, 'PublicInbox::Filter::SubjectTag', 'new object created');
 
-my $mime = Email::MIME->new(<<EOF);
+my $mime = PublicInbox::MIME->new(<<EOF);
 To: you <you\@example.com>
 Subject: =?UTF-8?B?UmU6IFtmb29dIEVsw4PCqWFub3I=?=
 
index 0f0562ed855078029ad497c01b4a3e1c409212c9..9d71f16d03c8463980f4742ad21f3be277d4be6d 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use_ok 'PublicInbox::Filter::Vger';
 
 my $f = PublicInbox::Filter::Vger->new;
@@ -21,7 +21,7 @@ More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/
 EOF
 
-       my $mime = Email::MIME->new($lkml);
+       my $mime = PublicInbox::MIME->new($lkml);
        $mime = $f->delivery($mime);
        is("keep this\n", $mime->body, 'normal message filtered OK');
 }
@@ -37,7 +37,7 @@ the body of a message to majordomo@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 EOF
 
-       my $mime = Email::MIME->new($no_nl);
+       my $mime = PublicInbox::MIME->new($no_nl);
        $mime = $f->delivery($mime);
        is('OSX users :P', $mime->body, 'missing trailing LF in original OK');
 }
index fda3962af646dfd52587eca56296e925637ac291..51897532f26a3f71ceaf1d13ccbba70ff5536301 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::Feed;
 use PublicInbox::Git;
 use PublicInbox::Import;
@@ -32,7 +32,7 @@ my $im = PublicInbox::Import->new($git, 'tester', 'test@example');
                        $mid_line .= "In-Reply-To: $prev";
                }
                $prev = $mid;
-               my $mime = Email::MIME->new(<<EOF);
+               my $mime = PublicInbox::MIME->new(<<EOF);
 From: ME <me\@example.com>
 To: U <u\@example.com>
 $mid_line
index 61aec3b4436bd5db64c09d46015488a391091ca8..f4fbd5330be2e0b874c579216eeff56ed7f7f12c 100644 (file)
--- a/t/httpd.t
+++ b/t/httpd.t
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use PublicInbox::TestCommon;
+use PublicInbox::MIME;
 use Socket qw(IPPROTO_TCP SOL_SOCKET);
 require_mods(qw(Plack::Util Plack::Builder HTTP::Date HTTP::Status));
 
@@ -20,7 +21,6 @@ my $sock = tcp_server();
 my $td;
 use_ok 'PublicInbox::Git';
 use_ok 'PublicInbox::Import';
-use_ok 'Email::MIME';
 {
        local $ENV{HOME} = $home;
        my $cmd = [ '-init', $group, $maindir, 'http://example.com/', $addr ];
@@ -28,7 +28,7 @@ use_ok 'Email::MIME';
 
        # ensure successful message delivery
        {
-               my $mime = Email::MIME->new(<<EOF);
+               my $mime = PublicInbox::MIME->new(<<EOF);
 From: Me <me\@example.com>
 To: You <you\@example.com>
 Cc: $addr
index 53345b12fb5b6ee54ec0b957028b3c7d9a54fc18..d2264102dc4fdbd0e544bdf762afdfb234570d61 100644 (file)
@@ -10,23 +10,21 @@ 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 = Email::MIME->create(
-       header => [
-               From => 'a@example.com',
-               To => 'b@example.com',
-               'Content-Type' => 'text/plain',
-               Subject => 'this is a subject',
-               'Message-ID' => '<a@example.com>',
-               Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-       ],
-       body => "hello world\n",
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: b@example.com
+Subject: this is a subject
+Message-ID: <a@example.com>
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+
+hello world
+EOF
+
 my $v2 = require_git(2.6, 1);
 my $smsg = {} if $v2;
 like($im->add($mime, undef, $smsg), qr/\A:[0-9]+\z/, 'added one message');
index 90506e2846fc1aa428403c77d1439686d649672b..dcd5dc39128ec8f0f3884e1f458cd117062e13d2 100644 (file)
@@ -10,17 +10,16 @@ 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 Email::MIME));
-
-my $mime = Email::MIME->create(
-       header => [
-               From => 'a@example.com',
-               To => 'test@example.com',
-               Subject => 'this is a subject',
-               Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-       ],
-       body => "hello world\n",
-);
+require_mods(qw(DBD::SQLite));
+
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: test@example.com
+Subject: this is a subject
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+
+hello world
+EOF
 
 sub import_index_incremental {
        my ($v, $level, $mime) = @_;
diff --git a/t/mid.t b/t/mid.t
index 9815d384966abc0d6d3f966c980cdbc660efceae..0ad81d7da8be71011bdb0cef047ecaec73519053 100644 (file)
--- a/t/mid.t
+++ b/t/mid.t
@@ -2,6 +2,7 @@
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use Test::More;
+use PublicInbox::MIME;
 use PublicInbox::MID qw(mid_escape mids references mids_for_index id_compress);
 
 is(mid_escape('foo!@(bar)'), 'foo!@(bar)');
@@ -15,10 +16,8 @@ like(id_compress('foo%bar@wtf'), qr/\A[a-f0-9]{40}\z/,
 is(id_compress('foobar-wtf'), 'foobar-wtf', 'regular ID not compressed');
 
 {
-       use Email::MIME;
-       my $mime = Email::MIME->create;
+       my $mime = PublicInbox::MIME->new("Message-ID: <mid-1\@a>\n\n");
        $mime->header_set('X-Alt-Message-ID', '<alt-id-for-nntp>');
-       $mime->header_set('Message-Id', '<mid-1@a>');
        is_deeply(['mid-1@a'], mids($mime->header_obj), 'mids in common case');
        $mime->header_set('Message-Id', '<mid-1@a>', '<mid-2@b>');
        is_deeply(['mid-1@a', 'mid-2@b'], mids($mime->header_obj), '2 mids');
index 058f38864b9934061360ab717f347725f2e79538..d9f8e6417d5bd3de73c636a5a1c2cf9327e7a0ec 100644 (file)
@@ -6,28 +6,23 @@ 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 = Email::MIME->create(
-               header => [
-                       From => 'a@example.com',
-                       To => 'b@example.com',
-                       'Content-Type' => 'text/plain',
-                       Subject => 'this is a subject',
-                       'Message-ID' => '<a@example.com>',
-                       Date => $date,
-                       'Received' => <<EOF,
-(majordomo\@vger.kernel.org) by vger.kernel.org via listexpand
-\tid S932173AbXAVSQY (ORCPT <rfc822;w\@1wt.eu>);
-\t$received_date
+       my $mime = PublicInbox::MIME->new(<<"EOF");
+From: a\@example.com
+To: b\@example.com
+Subject: this is a subject
+Message-ID: <a\@example.com>
+Date: $date
+Received: (majordomo\@vger.kernel.org) by vger.kernel.org via listexpand
+       id S932173AbXAVSQY (ORCPT <rfc822;w\@1wt.eu>);
+       $received_date
+
+hello world
 EOF
-               ],
-               body => "hello world\n",
-           );
        my @ts = PublicInbox::MsgTime::msg_datestamp($mime->header_obj);
        return \@ts;
 }
@@ -35,18 +30,18 @@ EOF
 sub timestamp ($) {
        my ($received) = @_;
        local $SIG{__WARN__} = sub {};  # Suppress warnings
-       my $mime = Email::MIME->create(
-               header => [
-                       From => 'a@example.com',
-                       To => 'b@example.com',
-                       'Content-Type' => 'text/plain',
-                       Subject => 'this is a subject',
-                       'Message-ID' => '<a@example.com>',
-                       Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-                       'Received' => '(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S932173AbXAVSQY (ORCPT <rfc822;w@1wt.eu>);\n\t' . $received,
-               ],
-               body => "hello world\n",
-           );
+       my $mime = PublicInbox::MIME->new(<<"EOF");
+From: a\@example.com
+To: b\@example.com
+Subject: this is a subject
+Message-ID: <a\@example.com>
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+Received: (majordomo\@vger.kernel.org) by vger.kernel.org via listexpand
+       id S932173AbXAVSQY (ORCPT <rfc822;w\@1wt.eu>);
+       $received
+
+hello world
+EOF
        my @ts = PublicInbox::MsgTime::msg_timestamp($mime->header_obj);
        return \@ts;
 }
index ff72ec6a001cabc92d725154608a7bda2956702a..35fb55b42ccfec723a2dfa734222d8aedd648b9c 100644 (file)
--- a/t/nntp.t
+++ b/t/nntp.t
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use PublicInbox::TestCommon;
+use PublicInbox::MIME;
 require_mods(qw(DBD::SQLite Data::Dumper));
 use_ok 'PublicInbox::NNTP';
 use_ok 'PublicInbox::Inbox';
@@ -96,7 +97,6 @@ use_ok 'PublicInbox::Inbox';
 }
 
 { # test setting NNTP headers in HEAD and ARTICLE requests
-       require Email::MIME;
        my $u = 'https://example.com/a/';
        my $ng = PublicInbox::Inbox->new({ name => 'test',
                                        inboxdir => 'test.git',
@@ -107,7 +107,7 @@ use_ok 'PublicInbox::Inbox';
                                        url => [ '//example.com/a' ]});
        is($ng->base_url, $u, 'URL expanded');
        my $mid = 'a@b';
-       my $mime = Email::MIME->new("Message-ID: <$mid>\r\n\r\n");
+       my $mime = PublicInbox::MIME->new("Message-ID: <$mid>\r\n\r\n");
        my $hdr = $mime->header_obj;
        my $mock_self = { nntpd => { grouplist => [], 
                                     servername => 'example.com' } };
index 5a3a62fbec9c7c13e273d0ee37c2723759fad11c..4993b29fe3f55c38e7f1591d81c942f9ffa68568 100644 (file)
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -7,7 +7,7 @@ use PublicInbox::TestCommon;
 use PublicInbox::Spawn qw(which);
 require_mods(qw(DBD::SQLite));
 require PublicInbox::InboxWritable;
-use Email::Simple;
+use PublicInbox::MIME;
 use IO::Socket;
 use Socket qw(IPPROTO_TCP TCP_NODELAY);
 use Net::NNTP;
@@ -57,7 +57,7 @@ $ibx = PublicInbox::Inbox->new($ibx);
 
        # ensure successful message delivery
        {
-               my $mime = Email::MIME->new(<<EOF);
+               my $mime = PublicInbox::MIME->new(<<EOF);
 To: =?utf-8?Q?El=C3=A9anor?= <you\@example.com>
 From: =?utf-8?Q?El=C3=A9anor?= <me\@example.com>
 Cc: $addr
index 1ded88d31f435fdad0fa3d792e5079e96ca08ee1..03b1ee80e711d13dbe1000b4f7a9b27b2bc7c202 100644 (file)
@@ -14,16 +14,14 @@ my $git_dir = "$tmpdir/a.git";
        my $git = PublicInbox::Git->new($git_dir);
        my $im = PublicInbox::Import->new($git, 'testbox', 'test@example');
        $im->init_bare;
-       $im->add(Email::MIME->create(
-               header => [
-                       From => 'a@example.com',
-                       To => 'b@example.com',
-                       'Content-Type' => 'text/plain',
-                       Subject => ' A subject line with a null =?iso-8859-1?q?=00?= see!',
-                       'Message-ID' => '<null-test.a@example.com>',
-               ],
-               body => "hello world\n",
-       ));
+       $im->add(PublicInbox::MIME->new(<<'EOF'));
+From: a@example.com
+To: b@example.com
+Subject: A subject line with a null =?iso-8859-1?q?=00?= see!
+Message-ID: <null-test.a@example.com>
+
+hello world
+EOF
        $im->done;
        is(xsys(qw(git --git-dir), $git_dir, 'fsck', '--strict'), 0,
                'git fsck ok');
index ea31879285fd6d89268677a6eb6941c11fffc6e7..b16bc8de9cd2bbae4d5c73cbcd9d77c98c694fbe 100644 (file)
--- a/t/plack.t
+++ b/t/plack.t
@@ -32,7 +32,7 @@ my $git = PublicInbox::Git->new($inboxdir);
 my $im = PublicInbox::Import->new($git, 'test', $addr);
 # ensure successful message delivery
 {
-       my $mime = Email::MIME->new(<<EOF);
+       my $mime = PublicInbox::MIME->new(<<EOF);
 From: Me <me\@example.com>
 To: You <you\@example.com>
 Cc: $addr
@@ -124,7 +124,7 @@ Date: Fri, 02 Oct 1993 00:00:00 +0000
 :(
 EOF
        $crlf =~ s/\n/\r\n/sg;
-       $im->add(Email::MIME->new($crlf));
+       $im->add(PublicInbox::MIME->new($crlf));
 
        $im->done;
 }
index a47f37540215a8efabca2d9254a114df5442f016..2376bba7bf2f042e099588da5499429cd679193d 100644 (file)
@@ -68,7 +68,7 @@ $im->init_bare;
        );
        $mime = $mime->as_string;
        $mime =~ s/\r\n/\n/g; # normalize to LF only
-       $mime = Email::MIME->new($mime);
+       $mime = PublicInbox::MIME->new($mime);
        $im->add($mime);
        $im->done;
 
index 3afb1fb59e7251850570729a9c9e9b601983ea6b..bd492dcb2ac372a2aec0720e3caa26339f2a1dae 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::TestCommon;
 my ($tmpdir, $for_destroy) = tmpdir();
 my $maindir = "$tmpdir/main.git";
@@ -25,7 +25,7 @@ my $git = PublicInbox::Git->new($maindir);
 my $im = PublicInbox::Import->new($git, 'test', $addr);
 $im->init_bare;
 {
-       my $mime = Email::MIME->new(<<EOF);
+       my $mime = PublicInbox::MIME->new(<<EOF);
 From: Me <me\@example.com>
 To: You <you\@example.com>
 Cc: $addr
index 7ef97d438593217a873e2ac6cb03bf340e2cee18..ef86c015f29143a27d45c0d1ac95285788d97406 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::Config;
 use PublicInbox::TestCommon;
 my @mods = qw(DBD::SQLite Search::Xapian HTTP::Request::Common
index 4d593941a38913d1f3692e19e90977ae94a38645..93603a332819a4a9dc62287ff74a429483762cb3 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::Config;
 use PublicInbox::TestCommon;
 my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape DBD::SQLite);
index 4fe315a1e2fdf32db4690699038143c4966a96f4..3c515d19b67a11c218bb6d347eece293d0457fb9 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::Config;
 use PublicInbox::Inbox;
 use PublicInbox::InboxWritable;
index 77fc9ee2dac45dd4b1782f962d803d345876e0cf..b7b5b2d456e1580c6576efe8d35175f99a39bdee 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::TestCommon;
 my ($tmpdir, $for_destroy) = tmpdir();
 my $maindir = "$tmpdir/main.git";
index fbb3e1b807554bcbbe5eb4ae88da60dd76b1459e..a6c38cfaaf2ba97cc4929994b930fbc2bab553cd 100644 (file)
--- a/t/reply.t
+++ b/t/reply.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use_ok 'PublicInbox::Reply';
 
 my @q = (
@@ -19,7 +19,7 @@ while (@q) {
        is($res, $expect, "quote $input => $res");
 }
 
-my $mime = Email::MIME->new(<<'EOF');
+my $mime = PublicInbox::MIME->new(<<'EOF');
 From: from <from@example.com>
 To: to <to@example.com>
 Cc: cc@example.com
index 6c564b19c0905b07687b8072c586652f5cd78b2f..1bea59fd87ae35c4988f4444fe1ff19cbaff3857 100644 (file)
@@ -6,7 +6,7 @@ use bytes (); # only for bytes::length
 use Test::More;
 use PublicInbox::TestCommon;
 use PublicInbox::MID qw(mids);
-use Email::MIME;
+use PublicInbox::MIME;
 require_mods(qw(DBD::SQLite Search::Xapian));
 require PublicInbox::SearchIdx;
 require PublicInbox::Smsg;
@@ -42,7 +42,7 @@ my @mids;
 
 foreach (reverse split(/\n\n/, $data)) {
        $_ .= "\n";
-       my $mime = Email::MIME->new(\$_);
+       my $mime = PublicInbox::MIME->new(\$_);
        $mime->header_set('From' => 'bw@g');
        $mime->header_set('To' => 'git@vger.kernel.org');
        my $bytes = bytes::length($mime->as_string);
@@ -78,7 +78,7 @@ $rw->commit_txn_lazy;
 
 $xdb = $rw->begin_txn_lazy;
 {
-       my $mime = Email::MIME->new(<<'');
+       my $mime = PublicInbox::MIME->new(<<'');
 Subject: [RFC 00/14]
 Message-Id: <1-bw@g>
 From: bw@g
index 8508f27301443d28d39a57bd54ed86cd0a38300a..0fd5fdeede0c6521d45cf2af2fad92fd5f3a3f98 100644 (file)
@@ -4,11 +4,11 @@ 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 PublicInbox::SearchIdx;
 require PublicInbox::Inbox;
 require PublicInbox::InboxWritable;
-use Email::MIME;
+use PublicInbox::MIME;
 my ($tmpdir, $for_destroy) = tmpdir();
 my $git_dir = "$tmpdir/a.git";
 my $ibx = PublicInbox::Inbox->new({ inboxdir => $git_dir });
@@ -60,27 +60,26 @@ sub oct_is ($$$) {
 }
 
 $ibx->with_umask(sub {
-       my $root = Email::MIME->create(
-               header_str => [
-                       Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-                       Subject => 'Hello world',
-                       'Message-ID' => '<root@s>',
-                       From => 'John Smith <js@example.com>',
-                       To => 'list@example.com',
-               ],
-               body => "\\m/\n");
-       my $last = Email::MIME->create(
-               header_str => [
-                       Date => 'Sat, 02 Oct 2010 00:00:00 +0000',
-                       Subject => 'Re: Hello world',
-                       'In-Reply-To' => '<root@s>',
-                       'Message-ID' => '<last@s>',
-                       From => 'John Smith <js@example.com>',
-                       To => 'list@example.com',
-                       Cc => 'foo@example.com',
-               ],
-               body => "goodbye forever :<\n");
-
+       my $root = PublicInbox::MIME->new(<<'EOF');
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+Subject: Hello world
+Message-ID: <root@s>
+From: John Smith <js@example.com>
+To: list@example.com
+
+\m/
+EOF
+       my $last = PublicInbox::MIME->new(<<'EOF');
+Date: Sat, 02 Oct 2010 00:00:00 +0000
+Subject: Re: Hello world
+In-Reply-To: <root@s>
+Message-ID: <last@s>
+From: John Smith <js@example.com>
+To: list@example.com
+Cc: foo@example.com
+
+goodbye forever :<
+EOF
        my $rv;
        $rw_commit->();
        $root_id = $rw->add_message($root);
@@ -127,31 +126,29 @@ sub filter_mids {
 $ibx->with_umask(sub {
        $rw_commit->();
        my $rmid = '<ghost-message@s>';
-       my $reply_to_ghost = Email::MIME->create(
-               header_str => [
-                       Date => 'Sat, 02 Oct 2010 00:00:00 +0000',
-                       Subject => 'Re: ghosts',
-                       'Message-ID' => '<ghost-reply@s>',
-                       'In-Reply-To' => $rmid,
-                       From => 'Time Traveler <tt@example.com>',
-                       To => 'list@example.com',
-               ],
-               body => "-_-\n");
-
+       my $reply_to_ghost = PublicInbox::MIME->new(<<"EOF");
+Date: Sat, 02 Oct 2010 00:00:00 +0000
+Subject: Re: ghosts
+Message-ID: <ghost-reply\@s>
+In-Reply-To: $rmid
+From: Time Traveler <tt\@example.com>
+To: list\@example.com
+
+-_-
+EOF
        my $rv;
        my $reply_id = $rw->add_message($reply_to_ghost);
        is($reply_id, int($reply_id), "reply_id is an integer: $reply_id");
 
-       my $was_ghost = Email::MIME->create(
-               header_str => [
-                       Date => 'Sat, 02 Oct 2010 00:00:01 +0000',
-                       Subject => 'ghosts',
-                       'Message-ID' => $rmid,
-                       From => 'Laggy Sender <lag@example.com>',
-                       To => 'list@example.com',
-               ],
-               body => "are real\n");
+       my $was_ghost = PublicInbox::MIME->new(<<"EOF");
+Date: Sat, 02 Oct 2010 00:00:01 +0000
+Subject: ghosts
+Message-ID: $rmid
+From: Laggy Sender <lag\@example.com>
+To: list\@example.com
 
+are real
+EOF
        my $ghost_id = $rw->add_message($was_ghost);
        is($ghost_id, int($ghost_id), "ghost_id is an integer: $ghost_id");
        my $msgs = $rw->{over}->get_thread('ghost-message@s');
@@ -192,18 +189,17 @@ $ibx->with_umask(sub {
        $rw_commit->();
        $ro->reopen;
        my $long_mid = 'last' . ('x' x 60). '@s';
-
-       my $long = Email::MIME->create(
-               header_str => [
-                       Date => 'Sat, 02 Oct 2010 00:00:00 +0000',
-                       Subject => 'long message ID',
-                       'References' => '<root@s> <last@s>',
-                       'In-Reply-To' => '<last@s>',
-                       'Message-ID' => "<$long_mid>",
-                       From => '"Long I.D." <long-id@example.com>',
-                       To => 'list@example.com',
-               ],
-               body => "wut\n");
+       my $long = PublicInbox::MIME->new(<<EOF);
+Date: Sat, 02 Oct 2010 00:00:00 +0000
+Subject: long message ID
+References: <root\@s> <last\@s>
+In-Reply-To: <last\@s>
+Message-ID: <$long_mid>,
+From: "Long I.D." <long-id\@example.com>
+To: list\@example.com
+
+wut
+EOF
        my $long_id = $rw->add_message($long);
        is($long_id, int($long_id), "long_id is an integer: $long_id");
 
@@ -213,18 +209,16 @@ $ibx->with_umask(sub {
        my @res;
 
        my $long_reply_mid = 'reply-to-long@1';
-       my $long_reply = Email::MIME->create(
-               header_str => [
-                       Subject => 'I break references',
-                       Date => 'Sat, 02 Oct 2010 00:00:00 +0000',
-                       'Message-ID' => "<$long_reply_mid>",
-                       # No References:
-                       # 'References' => '<root@s> <last@s> <'.$long_mid.'>',
-                       'In-Reply-To' => "<$long_mid>",
-                       From => 'no1 <no1@example.com>',
-                       To => 'list@example.com',
-               ],
-               body => "no References\n");
+       my $long_reply = PublicInbox::MIME->new(<<EOF);
+Subject: I break references
+Date: Sat, 02 Oct 2010 00:00:00 +0000
+Message-ID: <$long_reply_mid>
+In-Reply-To: <$long_mid>
+From: no1 <no1\@example.com>
+To: list\@example.com
+
+no References
+EOF
        ok($rw->add_message($long_reply) > $long_id, "inserted long reply");
 
        $rw_commit->();
@@ -239,25 +233,26 @@ $ibx->with_umask(sub {
 # quote prioritization
 $ibx->with_umask(sub {
        $rw_commit->();
-       $rw->add_message(Email::MIME->create(
-               header_str => [
-                       Date => 'Sat, 02 Oct 2010 00:00:01 +0000',
-                       Subject => 'Hello',
-                       'Message-ID' => '<quote@a>',
-                       From => 'Quoter <quoter@example.com>',
-                       To => 'list@example.com',
-               ],
-               body => "> theatre illusions\nfade\n"));
-
-       $rw->add_message(Email::MIME->create(
-               header_str => [
-                       Date => 'Sat, 02 Oct 2010 00:00:02 +0000',
-                       Subject => 'Hello',
-                       'Message-ID' => '<nquote@a>',
-                       From => 'Non-Quoter<non-quoter@example.com>',
-                       To => 'list@example.com',
-               ],
-               body => "theatre\nfade\n"));
+       $rw->add_message(PublicInbox::MIME->new(<<'EOF'));
+Date: Sat, 02 Oct 2010 00:00:01 +0000
+Subject: Hello
+Message-ID: <quote@a>
+From: Quoter <quoter@example.com>
+To: list@example.com
+
+> theatre illusions
+fade
+EOF
+       $rw->add_message(PublicInbox::MIME->new(<<'EOF'));
+Date: Sat, 02 Oct 2010 00:00:02 +0000
+Subject: Hello
+Message-ID: <nquote@a>
+From: Non-Quoter<non-quoter@example.com>
+To: list@example.com
+
+theatre
+fade
+EOF
        my $res = $rw->query("theatre");
        is(scalar(@$res), 2, "got both matches");
        is($res->[0]->mid, 'nquote@a', "non-quoted scores higher") if scalar(@$res);
@@ -272,17 +267,17 @@ $ibx->with_umask(sub {
 # circular references
 $ibx->with_umask(sub {
        my $s = 'foo://'. ('Circle' x 15).'/foo';
-       my $doc_id = $rw->add_message(Email::MIME->create(
-               header => [ Subject => $s ],
-               header_str => [
-                       Date => 'Sat, 02 Oct 2010 00:00:01 +0000',
-                       'Message-ID' => '<circle@a>',
-                       'References' => '<circle@a>',
-                       'In-Reply-To' => '<circle@a>',
-                       From => 'Circle <circle@example.com>',
-                       To => 'list@example.com',
-               ],
-               body => "LOOP!\n"));
+       my $doc_id = $rw->add_message(PublicInbox::MIME->new(<<EOF));
+Subject: $s
+Date: Sat, 02 Oct 2010 00:00:01 +0000
+Message-ID: <circle\@a>
+References: <circle\@a>
+In-Reply-To: <circle\@a>
+From: Circle <circle\@example.com>
+To: list\@example.com
+
+LOOP!
+EOF
        ok($doc_id > 0, "doc_id defined with circular reference");
        my $smsg = $rw->query('m:circle@a', {limit=>1})->[0];
        is(defined($smsg), 1, 'found m:circl@a');
@@ -462,15 +457,13 @@ $ibx->with_umask(sub {
        my $mid = "$ua.$digits.2460-100000\@penguin.transmeta.com";
        is($ro->reopen->query("m:$digits", { mset => 1})->size, 0,
                'no results yet');
-       my $pine = Email::MIME->create(
-               header_str => [
-                       Subject => 'blah',
-                       'Message-ID' => "<$mid>",
-                       From => 'torvalds@transmeta',
-                       To => 'list@example.com',
-               ],
-               body => ""
-       );
+       my $pine = PublicInbox::MIME->new(<<EOF);
+Subject: blah
+Message-ID: <$mid>
+From: torvalds\@transmeta
+To: list\@example.com
+
+EOF
        my $x = $rw->add_message($pine);
        $rw->commit_txn_lazy;
        is($ro->reopen->query("m:$digits", { mset => 1})->size, 1,
index 94bf9181061bbce7d8f41a810a0b394e90af20fe..71600b93b60114e78e1a9debc4f47913881f9c74 100644 (file)
--- a/t/time.t
+++ b/t/time.t
@@ -3,21 +3,20 @@
 use strict;
 use warnings;
 use Test::More;
-use_ok 'Email::MIME';
+use POSIX qw(strftime);
+use PublicInbox::MIME;
 use PublicInbox::MsgTime qw(msg_datestamp);
-my $mime = Email::MIME->create(
-       header => [
-               From => 'a@example.com',
-               To => 'test@example.com',
-               Subject => 'this is a subject',
-               'Message-ID' => '<a-mid@b>',
-               Date => 'Fri, 02 Oct 93 00:00:00 +0000',
-       ],
-       body => "hello world\n",
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: b@example.com
+Subject: this is a subject
+Message-ID: <a@example.com>
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+
+hello world
+EOF
 
 my $ts = msg_datestamp($mime->header_obj);
-use POSIX qw(strftime);
 is(strftime('%Y-%m-%d %H:%M:%S', gmtime($ts)), '1993-10-02 00:00:00',
        'got expected date with 2 digit year');
 $mime->header_set(Date => 'Fri, 02 Oct 101 01:02:03 +0000');
index c3a7e77f18b75607801fd1a8e9de875c942c60b7..23f4fb1181becc7f0a018cba8a5845da585ebc7a 100644 (file)
@@ -5,7 +5,8 @@ use warnings;
 use Test::More;
 use PublicInbox::Import;
 use PublicInbox::TestCommon;
-require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
+use PublicInbox::MIME;
+require_mods(qw(DBD::SQLite Search::Xapian));
 require PublicInbox::SearchIdx;
 my ($inboxdir, $for_destroy) = tmpdir();
 my $ibx = {
@@ -14,16 +15,15 @@ my $ibx = {
        -primary_address => 'test@example.com',
 };
 $ibx = PublicInbox::Inbox->new($ibx);
-my $mime = Email::MIME->create(
-       header => [
-               From => 'a@example.com',
-               To => 'test@example.com',
-               Subject => 'this is a subject',
-               Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-               'Message-ID' => '<a-mid@b>',
-       ],
-       body => "hello world\n",
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: test@example.com
+Subject: this is a subject
+Message-ID: <a-mid@b>
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+
+hello world
+EOF
 my $im = PublicInbox::Import->new($ibx->git, undef, undef, $ibx);
 $im->init_bare;
 ok($im->add($mime), 'message added');
index ce3833be35696a8d325bf28540a4f2644870ee7e..e473fe7c3942a95f2db6dbca31b10a0d6d733243 100644 (file)
@@ -6,8 +6,9 @@ use Test::More;
 use PublicInbox::ContentId qw(content_digest);
 use File::Path qw(remove_tree);
 use PublicInbox::TestCommon;
+use PublicInbox::MIME;
 require_git(2.6);
-require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
+require_mods(qw(DBD::SQLite Search::Xapian));
 use_ok 'PublicInbox::SearchIdx';
 use_ok 'PublicInbox::Import';
 my ($inboxdir, $for_destroy) = tmpdir();
@@ -17,15 +18,14 @@ my $ibx_config = {
        -primary_address => 'test@example.com',
        indexlevel => 'full',
 };
-my $mime = Email::MIME->create(
-       header => [
-               From => 'a@example.com',
-               To => 'test@example.com',
-               Subject => 'this is a subject',
-               Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-       ],
-       body => "hello world\n",
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: test@example.com
+Subject: this is a subject
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+
+hello world
+EOF
 my $minmax;
 my $msgmap;
 my ($mark1, $mark2, $mark3, $mark4);
index ca998334ce1a4510cf440c73e2abd18d4ce522a9..60a869eeb9d2462eeafdb21a431b96d27f5541ba 100644 (file)
@@ -3,9 +3,10 @@
 use strict;
 use warnings;
 use Test::More;
+use PublicInbox::MIME;
 use PublicInbox::TestCommon;
 require_git(2.6);
-require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
+require_mods(qw(DBD::SQLite Search::Xapian));
 use_ok 'PublicInbox::V2Writable';
 my ($inboxdir, $for_destroy) = tmpdir();
 my $ibx = {
@@ -15,16 +16,15 @@ my $ibx = {
        -primary_address => 'test@example.com',
 };
 $ibx = PublicInbox::Inbox->new($ibx);
-my $mime = Email::MIME->create(
-       header => [
-               From => 'a@example.com',
-               To => 'test@example.com',
-               Subject => 'this is a subject',
-               Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-               'Message-ID' => '<a-mid@b>',
-       ],
-       body => "hello world\n",
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: test@example.com
+Subject: this is a subject
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+Message-ID: <a-mid@b>
+
+hello world
+EOF
 my $im = PublicInbox::V2Writable->new($ibx, 1);
 $im->{parallel} = 0;
 ok($im->add($mime), 'message added');
index 94b63310b5a30bab420eb0cb31ef7c6a91ecde89..4d3ec30db91e4b99ac076826841d53e3e81a2ba0 100644 (file)
--- a/t/v2mda.t
+++ b/t/v2mda.t
@@ -6,10 +6,11 @@ use Test::More;
 use Fcntl qw(SEEK_SET);
 use Cwd;
 use PublicInbox::TestCommon;
+use PublicInbox::MIME;
 require_git(2.6);
 
 my $V = 2;
-require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
+require_mods(qw(DBD::SQLite Search::Xapian));
 use_ok 'PublicInbox::V2Writable';
 my ($tmpdir, $for_destroy) = tmpdir();
 my $ibx = {
@@ -17,18 +18,16 @@ my $ibx = {
        name => 'test-v2writable',
        address => [ 'test@example.com' ],
 };
-my $mime = Email::MIME->create(
-       header => [
-               From => 'a@example.com',
-               To => 'test@example.com',
-               Subject => 'this is a subject',
-               Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-               'Message-ID' => '<foo@bar>',
-               'List-ID' => '<test.example.com>',
-       ],
-       body => "hello world\n",
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: test@example.com
+Subject: this is a subject
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+Message-ID: <foo@bar>
+List-ID: <test.example.com>
 
+hello world
+EOF
 my $main_bin = getcwd()."/t/main-bin";
 my $fail_bin = getcwd()."/t/fail-bin";
 local $ENV{PI_DIR} = "$tmpdir/foo";
index 7bf6bc2f935f7f3ce9923d4a7b249b62dc5cb640..b97c6498c27b085c029b792392e10c5181b422a3 100644 (file)
@@ -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 Email::MIME));
+require_mods(qw(DBD::SQLite Search::Xapian));
 use_ok 'PublicInbox::V2Writable';
 my ($inboxdir, $for_destroy) = tmpdir();
 my $ibx_config = {
@@ -24,15 +24,13 @@ my $agpl = do {
        <$fh>;
 };
 my $phrase = q("defending all users' freedom");
-my $mime = Email::MIME->create(
-       header => [
-               From => 'a@example.com',
-               To => 'test@example.com',
-               Subject => 'this is a subject',
-               Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-       ],
-       body => $agpl,
-);
+my $mime = PublicInbox::MIME->new(<<'EOF'.$agpl);
+From: a@example.com
+To: test@example.com
+Subject: this is a subject
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+
+EOF
 my $minmax;
 my $msgmap;
 my ($mark1, $mark2, $mark3, $mark4);
index 7e7560b39b19446378c83baa9142809458e2d877..07687052c0b7fe4f99b9ab1e6fc1442de2e41e81 100644 (file)
@@ -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 Email::MIME));
+require_mods(qw(DBD::SQLite Search::Xapian));
 local $ENV{HOME} = abs_path('t');
 use_ok 'PublicInbox::V2Writable';
 umask 007;
@@ -20,17 +20,15 @@ my $ibx = {
        -primary_address => 'test@example.com',
 };
 $ibx = PublicInbox::Inbox->new($ibx);
-my $mime = Email::MIME->create(
-       header => [
-               From => 'a@example.com',
-               To => 'test@example.com',
-               Subject => 'this is a subject',
-               'Message-ID' => '<a-mid@b>',
-               Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-       ],
-       body => "hello world\n",
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: test@example.com
+Subject: this is a subject
+Message-ID: <a-mid@b>
+Date: Fri, 02 Oct 1993 00:00:00 +0000
 
+hello world
+EOF
 my $im = PublicInbox::V2Writable->new($ibx, {nproc => 1});
 is($im->{shards}, 1, 'one shard when forced');
 ok($im->add($mime), 'ordinary message added');
index 9ed04cab14138ca258e9b6bb325ef0e810f94a44..c34d15f799a6123d2e2429a0ca46d9c0027fbf53 100644 (file)
@@ -2,7 +2,7 @@
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use Test::More;
-use Email::MIME;
+use PublicInbox::MIME;
 use Cwd;
 use PublicInbox::Config;
 use PublicInbox::TestCommon;
index 2571329e51ec5e89729aefa72212b2c0b48c4e7b..0e1fea52d152a9415f502e97b7aeeae20579d28d 100644 (file)
@@ -4,22 +4,19 @@ use strict;
 use warnings;
 use Test::More;
 use PublicInbox::TestCommon;
-require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
+require_mods(qw(DBD::SQLite Search::Xapian));
 require_git('2.6');
 use PublicInbox::MIME;
 use PublicInbox::InboxWritable;
 require PublicInbox::Search;
 
-my $mime = Email::MIME->create(
-       header => [
-               From => 'a@example.com',
-               To => 'test@example.com',
-               Subject => 'this is a subject',
-               Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-       ],
-       body => '',
-);
+my $mime = PublicInbox::MIME->new(<<'EOF');
+From: a@example.com
+To: test@example.com
+Subject: this is a subject
+Date: Fri, 02 Oct 1993 00:00:00 +0000
 
+EOF
 my ($this) = (split('/', $0))[-1];
 my ($tmpdir, $for_destroy) = tmpdir();
 local $ENV{PI_CONFIG} = "$tmpdir/config";