X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fmime.t;h=72140ebf372cf47e1447b0092fe0dcad441c053a;hb=3d41aa23f35501ca92aab8aa42980fa73f7fa74f;hp=cd3303d1457d8a8a3d12305d10c582572f4f27af;hpb=3fc59df0d633a17e0c5e43d633d12e8772c06ec3;p=public-inbox.git diff --git a/t/mime.t b/t/mime.t index cd3303d1..72140ebf 100644 --- a/t/mime.t +++ b/t/mime.t @@ -1,4 +1,4 @@ -# Copyright (C) 2017 all contributors +# Copyright (C) 2017-2018 all contributors # This library is free software; you can redistribute it and/or modify # it under the same terms as Perl itself. # Artistic or GPL-1+ @@ -6,7 +6,9 @@ use strict; use warnings; use Test::More; use_ok 'PublicInbox::MIME'; +use PublicInbox::MsgIter; +local $SIG{__WARN__} = sub {}; my $msg = PublicInbox::MIME->new( 'From: Richard Hansen To: git@vger.kernel.org @@ -54,4 +56,63 @@ my $exp = 'Richard Hansen (2): ok($msg->isa('Email::MIME'), 'compatible with Email::MIME'); is($parts[0]->body, $exp, 'body matches expected'); + +my $raw = q^Date: Wed, 18 Jan 2017 13:28:32 -0500 +From: Santiago Torres +To: Junio C Hamano +Cc: git@vger.kernel.org, peff@peff.net, sunshine@sunshineco.com, + walters@verbum.org, Lukas Puehringer +Subject: Re: [PATCH v6 4/6] builtin/tag: add --format argument for tag -v +Message-ID: <20170118182831.pkhqu2np3bh2puei@LykOS.localdomain> +References: <20170117233723.23897-1-santiago@nyu.edu> + <20170117233723.23897-5-santiago@nyu.edu> + + +MIME-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha256; + protocol="application/pgp-signature"; boundary="r24xguofrazenjwe" +Content-Disposition: inline +In-Reply-To: + + +--r24xguofrazenjwe +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +your tree directly?=20 + +--r24xguofrazenjwe +Content-Type: application/pgp-signature; name="signature.asc" + +-----BEGIN PGP SIGNATURE----- + +=7wIb +-----END PGP SIGNATURE----- + +--r24xguofrazenjwe-- + +^; + +$msg = PublicInbox::MIME->new($raw); +my $nr = 0; +msg_iter($msg, sub { + my ($part, $level, @ex) = @{$_[0]}; + if ($ex[0] == 1) { + is($part->body_str, "your tree directly? \r\n", 'body OK'); + } elsif ($ex[0] == 2) { + is($part->body, "-----BEGIN PGP SIGNATURE-----\n\n" . + "=7wIb\n" . + "-----END PGP SIGNATURE-----\n", + 'sig "matches"'); + } else { + fail "unexpected part\n"; + } + $nr++; +}); + +is($nr, 2, 'got 2 parts'); +is($msg->as_string, $raw, + 'stringified sufficiently close to original'); + done_testing();