dde25abc2fa7c0b0e6b175178b4e740a4a979c50
[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: text/plain
62 This is an inline text part.
63 \fpart}
64 \fattachment{ ID: 2, Content-type: text/plain
65 Attachment: attachment (text/plain)
66 This is a text attachment.
67 \fattachment}
68 \fpart{ ID: 3, Content-type: text/plain
69 And this message is signed.
70
71 -Carl
72 \fpart}
73 \fpart{ ID: 4, Content-type: application/pgp-signature
74 Non-text part: application/pgp-signature
75 \fpart}
76 \fbody}
77 \fmessage}"
78
79 test_begin_subtest "Show multipart MIME message (--format=json)"
80 output=$(notmuch show --format=json 'id:87liy5ap00.fsf@yoom.home.cworth.org')
81 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"}]}, []]]]'
82
83 test_done
84