]> git.notmuchmail.org Git - notmuch/blob - test/multipart
notmuch show: Include output for the enclosing multipart part of a MIME mail
[notmuch] / test / multipart
1 #!/bin/bash
2 test_description="output of multipart message"
3 . ./test-lib.sh
4
5 cat <<EOF > ${MAIL_DIR}/multipart
6 From: Carl Worth <cworth@cworth.org>
7 To: cworth@cworth.org
8 Subject: Multipart message
9 Date: Tue, 05 Jan 2001 15:43:57 -0000
10 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
11 Message-ID: <87liy5ap00.fsf@yoom.home.cworth.org>
12 MIME-Version: 1.0
13 Content-Type: multipart/signed; boundary="==-=-=";
14         micalg=pgp-sha1; protocol="application/pgp-signature"
15
16 --==-=-=
17 Content-Type: multipart/mixed; boundary="=-=-="
18
19 --=-=-=
20
21 This is an inline text part.
22
23 --=-=-=
24 Content-Disposition: attachment; filename=attachment
25
26 This is a text attachment.
27
28 --=-=-=
29
30 And this message is signed.
31
32 -Carl
33
34 --=-=-=--
35
36 --==-=-=
37 Content-Type: application/pgp-signature
38
39 -----BEGIN PGP SIGNATURE-----
40 Version: GnuPG v1.4.11 (GNU/Linux)
41
42 iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
43 W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
44 =zkga
45 -----END PGP SIGNATURE-----
46 --==-=-=--
47 EOF
48 notmuch new > /dev/null
49
50 test_begin_subtest "Show multipart MIME message (--format=text)"
51 output=$(notmuch show --format=text 'id:87liy5ap00.fsf@yoom.home.cworth.org')
52 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
53 \fheader{
54 Carl Worth <cworth@cworth.org> (2001-01-05) (attachment inbox unread)
55 Subject: Multipart message
56 From: Carl Worth <cworth@cworth.org>
57 To: cworth@cworth.org
58 Date: Tue, 05 Jan 2001 15:43:57 -0000
59 \fheader}
60 \fbody{
61 \fpart{ ID: 1, Content-type: multipart/signed
62 \fpart}
63 \fpart{ ID: 2, Content-type: multipart/mixed
64 \fpart}
65 \fpart{ ID: 3, Content-type: text/plain
66 This is an inline text part.
67 \fpart}
68 \fattachment{ ID: 4, Content-type: text/plain
69 Attachment: attachment (text/plain)
70 This is a text attachment.
71 \fattachment}
72 \fpart{ ID: 5, Content-type: text/plain
73 And this message is signed.
74
75 -Carl
76 \fpart}
77 \fpart{ ID: 6, Content-type: application/pgp-signature
78 Non-text part: application/pgp-signature
79 \fpart}
80 \fbody}
81 \fmessage}"
82
83 test_begin_subtest "Show multipart MIME message (--format=json)"
84 output=$(notmuch show --format=json 'id:87liy5ap00.fsf@yoom.home.cworth.org')
85 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": "multipart/signed"}, {"id": 2, "content-type": "multipart/mixed"}, {"id": 3, "content-type": "text/plain", "content": "This is an inline text part.\n"}, {"id": 4, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, {"id": 5, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}, {"id": 6, "content-type": "application/pgp-signature"}]}, []]]]'
86
87 test_done
88