]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/mbox_reader.t
No ext_urls
[public-inbox.git] / t / mbox_reader.t
index da0ce7f1e58aff03c0c82eebfaf7536e550af96f..87e8f397662cd058aafc0075a23d4377e2c0abaa 100644 (file)
@@ -71,6 +71,12 @@ my $check_fmt = sub {
                                "Content-Length is correct $fmt $cur");
                        # clobber for ->as_string comparison below
                        $eml->header_set('Content-Length');
+
+                       # special case for t/solve/bare.patch, not sure if we
+                       # should even handle it...
+                       if ($cl[0] eq '0' && ${$eml->{hdr}} eq '') {
+                               delete $eml->{bdy};
+                       }
                } else {
                        is(scalar(@cl), 0, "Content-Length unset $fmt $cur");
                }
@@ -121,4 +127,25 @@ exit 1
        is(scalar(grep(/Final/, @x)), 0, 'no incomplete bit');
 }
 
+{
+       my $html = <<EOM;
+<html><head><title>hi,</title></head><body>how are you</body></html>
+EOM
+       for my $m (qw(mboxrd mboxcl mboxcl2 mboxo)) {
+               my (@w, @x);
+               local $SIG{__WARN__} = sub { push @w, @_ };
+               open my $fh, '<', \$html or xbail 'PerlIO::scalar';
+               PublicInbox::MboxReader->$m($fh, sub {
+                       push @x, $_[0]->as_string
+               });
+               if ($m =~ /\Amboxcl/) {
+                       is_deeply(\@x, [], "messages in invalid $m");
+               } else {
+                       is_deeply(\@x, [ "\n$html" ], "body-only $m");
+               }
+               is_deeply([grep(!/^W: leftover/, @w)], [],
+                       "no extra warnings besides leftover ($m)");
+       }
+}
+
 done_testing;