about summary refs log tree commit homepage
path: root/t/eml.t
diff options
context:
space:
mode:
Diffstat (limited to 't/eml.t')
-rw-r--r--t/eml.t24
1 files changed, 19 insertions, 5 deletions
diff --git a/t/eml.t b/t/eml.t
index ebd45c13..690ada57 100644
--- a/t/eml.t
+++ b/t/eml.t
@@ -1,8 +1,8 @@
 #!perl -w
-# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+use v5.10.1; # TODO: check unicode_strings w/ 5.12
 use strict;
-use Test::More;
 use PublicInbox::TestCommon;
 use PublicInbox::MsgIter qw(msg_part_text);
 my @classes = qw(PublicInbox::Eml);
@@ -26,6 +26,8 @@ sub mime_load ($) {
         is($str, "hi\n", '->new modified body like Email::Simple');
         is($eml->body, "hi\n", '->body works');
         is($eml->as_string, "a: b\n\nhi\n", '->as_string');
+        my $empty = PublicInbox::Eml->new("\n\n");
+        is($empty->as_string, "\n\n", 'empty message');
 }
 
 for my $cls (@classes) {
@@ -214,6 +216,17 @@ if ('one newline before headers') {
         is($eml->body, "");
 }
 
+if ('body only') {
+        my $str = <<EOM;
+--- a/lib/PublicInbox/Eml.pm
++++ b/lib/PublicInbox/Eml.pm
+@@ -122,9 +122,10 @@ sub new {
+\x20
+EOM
+        my $eml = PublicInbox::Eml->new($str);
+        is($eml->body, $str, 'body-only accepted');
+}
+
 for my $cls (@classes) { # XXX: matching E::M, but not sure about this
         my $s = <<EOF;
 Content-Type: multipart/mixed; boundary="b"
@@ -342,7 +355,7 @@ if ('maxparts is a feature unique to us') {
 }
 
 SKIP: {
-        require_mods('PublicInbox::MIME', 1);
+        require_mods('Email::MIME', 1);
         my $eml = eml_load 't/utf8.eml';
         my $mime = mime_load 't/utf8.eml';
         for my $h (qw(Subject From To)) {
@@ -404,13 +417,14 @@ Content-Type: text/x-patch; name="=?utf-8?q?vtpm-fakefile.patch?="
 Content-Disposition: attachment; filename="=?utf-8?q?vtpm-makefile.patch?="
 
 EOF
-        is($cls->new($s)->filename, 'vtpm-makefile.patch', 'filename decoded');
+        is($cls->new($s)->filename, 'vtpm-makefile.patch',
+                "filename decoded ($cls)") if $cls ne 'PublicInbox::MIME';
         $s =~ s/^Content-Disposition:.*$//sm;
         is($cls->new($s)->filename, 'vtpm-fakefile.patch',
                 "filename fallback ($cls)") if $cls ne 'PublicInbox::MIME';
         is($cls->new($s)->content_type,
                 'text/x-patch; name="vtpm-fakefile.patch"',
-                'matches Email::MIME output, "correct" or not');
+                qq[matches Email::MIME output, "correct" or not ($cls)]);
 
         $s = <<'EOF';
 Content-Type: multipart/foo; boundary=b