]> git.notmuchmail.org Git - notmuch/commitdiff
test: Add a test of "notmuch show" with a multipart message
authorCarl Worth <cworth@cworth.org>
Mon, 16 May 2011 22:25:25 +0000 (15:25 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 17 May 2011 05:21:31 +0000 (22:21 -0700)
This tests "notmuch show" with both --format=text and --format=json on
a message with some non-trivial MIME multipart nesting, (multiple parts
within a multipart/mixed part which is within a multipart/signed part).

The test captures the current behavior (where only the leaf nodes of
the MIME structure are emitted as a flat list---the multipart parts
are effectively ignored). We plan to soon change the json output at
least to emit an actual hierarchy matching the MIME structure, (at
which point we will update this test).

test/multipart [new file with mode: 0755]
test/notmuch-test

diff --git a/test/multipart b/test/multipart
new file mode 100755 (executable)
index 0000000..dde25ab
--- /dev/null
@@ -0,0 +1,84 @@
+#!/bin/bash
+test_description="output of multipart message"
+. ./test-lib.sh
+
+cat <<EOF > ${MAIL_DIR}/multipart
+From: Carl Worth <cworth@cworth.org>
+To: cworth@cworth.org
+Subject: Multipart message
+Date: Tue, 05 Jan 2001 15:43:57 -0000
+User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
+Message-ID: <87liy5ap00.fsf@yoom.home.cworth.org>
+MIME-Version: 1.0
+Content-Type: multipart/signed; boundary="==-=-=";
+       micalg=pgp-sha1; protocol="application/pgp-signature"
+
+--==-=-=
+Content-Type: multipart/mixed; boundary="=-=-="
+
+--=-=-=
+
+This is an inline text part.
+
+--=-=-=
+Content-Disposition: attachment; filename=attachment
+
+This is a text attachment.
+
+--=-=-=
+
+And this message is signed.
+
+-Carl
+
+--=-=-=--
+
+--==-=-=
+Content-Type: application/pgp-signature
+
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.11 (GNU/Linux)
+
+iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
+W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
+=zkga
+-----END PGP SIGNATURE-----
+--==-=-=--
+EOF
+notmuch new > /dev/null
+
+test_begin_subtest "Show multipart MIME message (--format=text)"
+output=$(notmuch show --format=text 'id:87liy5ap00.fsf@yoom.home.cworth.org')
+test_expect_equal "$output" "\fmessage{ id:87liy5ap00.fsf@yoom.home.cworth.org depth:0 match:1 filename:/home/cworth/src/notmuch/test/tmp.multipart/mail/multipart
+\fheader{
+Carl Worth <cworth@cworth.org> (2001-01-05) (attachment inbox unread)
+Subject: Multipart message
+From: Carl Worth <cworth@cworth.org>
+To: cworth@cworth.org
+Date: Tue, 05 Jan 2001 15:43:57 -0000
+\fheader}
+\fbody{
+\fpart{ ID: 1, Content-type: text/plain
+This is an inline text part.
+\fpart}
+\fattachment{ ID: 2, Content-type: text/plain
+Attachment: attachment (text/plain)
+This is a text attachment.
+\fattachment}
+\fpart{ ID: 3, Content-type: text/plain
+And this message is signed.
+
+-Carl
+\fpart}
+\fpart{ ID: 4, Content-type: application/pgp-signature
+Non-text part: application/pgp-signature
+\fpart}
+\fbody}
+\fmessage}"
+
+test_begin_subtest "Show multipart MIME message (--format=json)"
+output=$(notmuch show --format=json 'id:87liy5ap00.fsf@yoom.home.cworth.org')
+test_expect_equal "$output" '[[[{"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "filename": "/home/cworth/src/notmuch/test/tmp.multipart/mail/multipart", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Cc": "", "Bcc": "", "Date": "Tue, 05 Jan 2001 15:43:57 -0000"}, "body": [{"id": 1, "content-type": "text/plain", "content": "This is an inline text part.\n"}, {"id": 2, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, {"id": 3, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}, {"id": 4, "content-type": "application/pgp-signature"}]}, []]]]'
+
+test_done
+
index 8dd9c1ecf097d69e6084e25ada74bcc8af3102a8..72f1eecc6185b1f4f005beb4f90f6f4bac2a7c19 100755 (executable)
@@ -25,6 +25,7 @@ TESTS="
   search-position-overlap-bug
   search-insufficient-from-quoting
   json
+  multipart
   thread-naming
   raw
   reply