X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fmbox_reader.t;h=87e8f397662cd058aafc0075a23d4377e2c0abaa;hb=4eee5af6011cc8cdefb66c9729952c7eff5c0b0b;hp=18d0fd6818a35f4ac519347fd48cd1fe18231c2d;hpb=376778b910cdf787d6e08cfd11acab26118899f4;p=public-inbox.git diff --git a/t/mbox_reader.t b/t/mbox_reader.t index 18d0fd68..87e8f397 100644 --- a/t/mbox_reader.t +++ b/t/mbox_reader.t @@ -24,6 +24,16 @@ my %raw = ( (("b: ".('b' x 72)."\n") x 1000) . "From hell\n", ); +{ + my $eml = PublicInbox::Eml->new($raw{small}); + my $mbox_keywords = PublicInbox::MboxReader->can('mbox_keywords'); + is_deeply($mbox_keywords->($eml), [], 'no keywords'); + $eml->header_set('Status', 'RO'); + is_deeply($mbox_keywords->($eml), ['seen'], 'seen extracted'); + $eml->header_set('X-Status', 'A'); + is_deeply($mbox_keywords->($eml), [qw(answered seen)], + 'seen+answered extracted'); +} if ($ENV{TEST_EXTRA}) { for my $fn (glob('t/*.eml'), glob('t/*/*.{patch,eml}')) { @@ -61,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"); } @@ -111,4 +127,25 @@ exit 1 is(scalar(grep(/Final/, @x)), 0, 'no incomplete bit'); } +{ + my $html = <hi,how are you +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;