Re: [PATCH] lib: provide _notmuch_database_log_append
[notmuch-archives.git] / ac / 5cbc2cf4bba1c789aa5ae2ea587ac30998ebe5
1 Return-Path: <jrollins@finestructure.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 60A7F431FD0\r
6         for <notmuch@notmuchmail.org>; Mon,  5 Sep 2011 12:01:55 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id xfnjeu8euJDH for <notmuch@notmuchmail.org>;\r
16         Mon,  5 Sep 2011 12:01:53 -0700 (PDT)\r
17 Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
18         [131.215.239.19])\r
19         by olra.theworths.org (Postfix) with ESMTP id 3F144431FB6\r
20         for <notmuch@notmuchmail.org>; Mon,  5 Sep 2011 12:01:53 -0700 (PDT)\r
21 Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
22         by fire-doxen-postvirus (Postfix) with ESMTP id 8775B328142\r
23         for <notmuch@notmuchmail.org>; Mon,  5 Sep 2011 12:01:50 -0700 (PDT)\r
24 X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new\r
25 Received: from finestructure.net (cpe-76-166-145-155.socal.res.rr.com\r
26         [76.166.145.155]) (Authenticated sender: jrollins)\r
27         by fire-doxen-submit (Postfix) with ESMTP id 02B93328136\r
28         for <notmuch@notmuchmail.org>; Mon,  5 Sep 2011 12:01:46 -0700 (PDT)\r
29 Received: by finestructure.net (Postfix, from userid 1000)\r
30         id 2E3B2E3D; Mon,  5 Sep 2011 12:01:46 -0700 (PDT)\r
31 From: Jameson Graef Rollins <jrollins@finestructure.net>\r
32 To: Notmuch Mail <notmuch@notmuchmail.org>\r
33 Subject: [PATCH] test: overhaul multipart test to test for improved\r
34         message/rfc822 handling\r
35 Date: Mon,  5 Sep 2011 12:01:46 -0700\r
36 Message-Id: <1315249306-22328-1-git-send-email-jrollins@finestructure.net>\r
37 X-Mailer: git-send-email 1.7.5.4\r
38 In-Reply-To: <1307320169-29905-4-git-send-email-jrollins@finestructure.net>\r
39 References: <1307320169-29905-4-git-send-email-jrollins@finestructure.net>\r
40 X-BeenThere: notmuch@notmuchmail.org\r
41 X-Mailman-Version: 2.1.13\r
42 Precedence: list\r
43 List-Id: "Use and development of the notmuch mail system."\r
44         <notmuch.notmuchmail.org>\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
48 List-Post: <mailto:notmuch@notmuchmail.org>\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
51         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
52 X-List-Received-Date: Mon, 05 Sep 2011 19:01:55 -0000\r
53 \r
54 The main goal of this overhaul is to define how message/rfc822 parts\r
55 should be handled.  message/rfc822 parts should be output in a similar\r
56 fashion to the outer message, including some subset of the rfc822\r
57 headers.  The following decisions about formatting of message/rfc822\r
58 parts were made:\r
59 \r
60 The format and content of message/rfc822 parts shall be as similar as\r
61 possible to that of full messages.  In particular, for formatted\r
62 outputs, the "content" of rfc822 part output should include "headers"\r
63 and "body" fields).\r
64 \r
65 The "body" field shall include the body of the message.\r
66 \r
67 The "headers" field shall include the following headers, since these\r
68 are the ones available from the GMimeMessage:\r
69 \r
70   "From"\r
71   "To"\r
72   "Cc"\r
73   "Subject"\r
74   "Date"\r
75 \r
76 However, for the case of --format=raw the raw rfc822 should be output,\r
77 including all headers.\r
78 \r
79 A subset of relevant headers shall be output in reply.\r
80 \r
81 The test embedded rfc822 message is also modified to be itself\r
82 multipart, so we can more fully test how all sub parts of the message\r
83 part are output.\r
84 ---\r
85 This updated patch fixes some conflicts with the current master head.\r
86 \r
87  test/multipart |  368 +++++++++++++++++++++++++++++++++++++++++++-------------\r
88  1 files changed, 283 insertions(+), 85 deletions(-)\r
89 \r
90 diff --git a/test/multipart b/test/multipart\r
91 index ef859d1..0fd1c7e 100755\r
92 --- a/test/multipart\r
93 +++ b/test/multipart\r
94 @@ -2,6 +2,29 @@\r
95  test_description="output of multipart message"\r
96  . ./test-lib.sh\r
97  \r
98 +cat <<EOF > embedded_message\r
99 +From: Carl Worth <cworth@cworth.org>\r
100 +To: cworth@cworth.org\r
101 +Subject: html message\r
102 +Date: Fri, 05 Jan 2001 15:42:57 +0000\r
103 +User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)\r
104 +Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org>\r
105 +MIME-Version: 1.0\r
106 +Content-Type: multipart/alternative; boundary="==-=-=="\r
107 +\r
108 +--==-=-==\r
109 +Content-Type: text/html\r
110 +\r
111 +<p>This is an embedded message, with a multipart/alternative part.</p>\r
112 +\r
113 +--==-=-==\r
114 +Content-Type: text/plain\r
115 +\r
116 +This is an embedded message, with a multipart/alternative part.\r
117 +\r
118 +--==-=-==--\r
119 +EOF\r
120 +\r
121  cat <<EOF > ${MAIL_DIR}/multipart\r
122  From: Carl Worth <cworth@cworth.org>\r
123  To: cworth@cworth.org\r
124 @@ -20,17 +43,9 @@ Content-Type: multipart/mixed; boundary="=-=-="\r
125  Content-Type: message/rfc822\r
126  Content-Disposition: inline\r
127  \r
128 -From: Carl Worth <cworth@cworth.org>\r
129 -To: cworth@cworth.org\r
130 -Subject: html message\r
131 -Date: Fri, 05 Jan 2001 15:42:57 +0000\r
132 -User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)\r
133 -Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org>\r
134 -MIME-Version: 1.0\r
135 -Content-Type: text/html\r
136 -\r
137 -<p>This is an embedded message, with a single html part.</p>\r
138 -\r
139 +EOF\r
140 +cat embedded_message >> ${MAIL_DIR}/multipart\r
141 +cat <<EOF >> ${MAIL_DIR}/multipart\r
142  --=-=-=\r
143  Content-Disposition: attachment; filename=attachment\r
144  \r
145 @@ -105,20 +120,33 @@ Date: Fri, 05 Jan 2001 15:43:57 +0000\r
146  \f\r
147 part{ ID: 1, Content-type: multipart/signed\r
148  \f\r
149 part{ ID: 2, Content-type: multipart/mixed\r
150  \f\r
151 part{ ID: 3, Content-type: message/rfc822\r
152 -\f\r
153 part{ ID: 4, Content-type: text/html\r
154 +\f\r
155 header{\r
156 +From: Carl Worth <cworth@cworth.org>\r
157 +To: cworth@cworth.org\r
158 +Subject: html message\r
159 +Date: Fri, 05 Jan 2001 15:42:57 +0000\r
160 +\f\r
161 header}\r
162 +\f\r
163 body{\r
164 +\f\r
165 part{ ID: 4, Content-type: multipart/alternative\r
166 +\f\r
167 part{ ID: 5, Content-type: text/html\r
168  Non-text part: text/html\r
169  \f\r
170 part}\r
171 +\f\r
172 part{ ID: 6, Content-type: text/plain\r
173 +This is an embedded message, with a multipart/alternative part.\r
174 +\f\r
175 part}\r
176 +\f\r
177 part}\r
178 +\f\r
179 body}\r
180  \f\r
181 part}\r
182 -\f\r
183 attachment{ ID: 5, Filename: attachment, Content-type: text/plain\r
184 +\f\r
185 attachment{ ID: 7, Filename: attachment, Content-type: text/plain\r
186  This is a text attachment.\r
187  \f\r
188 attachment}\r
189 -\f\r
190 part{ ID: 6, Content-type: text/plain\r
191 +\f\r
192 part{ ID: 8, Content-type: text/plain\r
193  And this message is signed.\r
194  \r
195  -Carl\r
196  \f\r
197 part}\r
198  \f\r
199 part}\r
200 -\f\r
201 part{ ID: 7, Content-type: application/pgp-signature\r
202 +\f\r
203 part{ ID: 9, Content-type: application/pgp-signature\r
204  Non-text part: application/pgp-signature\r
205  \f\r
206 part}\r
207  \f\r
208 part}\r
209 @@ -133,20 +161,33 @@ cat <<EOF >EXPECTED\r
210  \f\r
211 part{ ID: 1, Content-type: multipart/signed\r
212  \f\r
213 part{ ID: 2, Content-type: multipart/mixed\r
214  \f\r
215 part{ ID: 3, Content-type: message/rfc822\r
216 -\f\r
217 part{ ID: 4, Content-type: text/html\r
218 +\f\r
219 header{\r
220 +From: Carl Worth <cworth@cworth.org>\r
221 +To: cworth@cworth.org\r
222 +Subject: html message\r
223 +Date: Fri, 05 Jan 2001 15:42:57 +0000\r
224 +\f\r
225 header}\r
226 +\f\r
227 body{\r
228 +\f\r
229 part{ ID: 4, Content-type: multipart/alternative\r
230 +\f\r
231 part{ ID: 5, Content-type: text/html\r
232  Non-text part: text/html\r
233  \f\r
234 part}\r
235 +\f\r
236 part{ ID: 6, Content-type: text/plain\r
237 +This is an embedded message, with a multipart/alternative part.\r
238 +\f\r
239 part}\r
240  \f\r
241 part}\r
242 -\f\r
243 attachment{ ID: 5, Filename: attachment, Content-type: text/plain\r
244 +\f\r
245 body}\r
246 +\f\r
247 part}\r
248 +\f\r
249 attachment{ ID: 7, Filename: attachment, Content-type: text/plain\r
250  This is a text attachment.\r
251  \f\r
252 attachment}\r
253 -\f\r
254 part{ ID: 6, Content-type: text/plain\r
255 +\f\r
256 part{ ID: 8, Content-type: text/plain\r
257  And this message is signed.\r
258  \r
259  -Carl\r
260  \f\r
261 part}\r
262  \f\r
263 part}\r
264 -\f\r
265 part{ ID: 7, Content-type: application/pgp-signature\r
266 +\f\r
267 part{ ID: 9, Content-type: application/pgp-signature\r
268  Non-text part: application/pgp-signature\r
269  \f\r
270 part}\r
271  \f\r
272 part}\r
273 @@ -158,14 +199,27 @@ notmuch show --format=text --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OU\r
274  cat <<EOF >EXPECTED\r
275  \f\r
276 part{ ID: 2, Content-type: multipart/mixed\r
277  \f\r
278 part{ ID: 3, Content-type: message/rfc822\r
279 -\f\r
280 part{ ID: 4, Content-type: text/html\r
281 +\f\r
282 header{\r
283 +From: Carl Worth <cworth@cworth.org>\r
284 +To: cworth@cworth.org\r
285 +Subject: html message\r
286 +Date: Fri, 05 Jan 2001 15:42:57 +0000\r
287 +\f\r
288 header}\r
289 +\f\r
290 body{\r
291 +\f\r
292 part{ ID: 4, Content-type: multipart/alternative\r
293 +\f\r
294 part{ ID: 5, Content-type: text/html\r
295  Non-text part: text/html\r
296  \f\r
297 part}\r
298 +\f\r
299 part{ ID: 6, Content-type: text/plain\r
300 +This is an embedded message, with a multipart/alternative part.\r
301 +\f\r
302 part}\r
303  \f\r
304 part}\r
305 -\f\r
306 attachment{ ID: 5, Filename: attachment, Content-type: text/plain\r
307 +\f\r
308 body}\r
309 +\f\r
310 part}\r
311 +\f\r
312 attachment{ ID: 7, Filename: attachment, Content-type: text/plain\r
313  This is a text attachment.\r
314  \f\r
315 attachment}\r
316 -\f\r
317 part{ ID: 6, Content-type: text/plain\r
318 +\f\r
319 part{ ID: 8, Content-type: text/plain\r
320  And this message is signed.\r
321  \r
322  -Carl\r
323 @@ -174,39 +228,75 @@ And this message is signed.\r
324  EOF\r
325  test_expect_equal_file OUTPUT EXPECTED\r
326  \r
327 -test_begin_subtest "--format=text --part=3, rfc822 multipart"\r
328 +test_begin_subtest "--format=text --part=3, rfc822 part"\r
329  notmuch show --format=text --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
330  cat <<EOF >EXPECTED\r
331  \f\r
332 part{ ID: 3, Content-type: message/rfc822\r
333 -\f\r
334 part{ ID: 4, Content-type: text/html\r
335 +\f\r
336 header{\r
337 +From: Carl Worth <cworth@cworth.org>\r
338 +To: cworth@cworth.org\r
339 +Subject: html message\r
340 +Date: Fri, 05 Jan 2001 15:42:57 +0000\r
341 +\f\r
342 header}\r
343 +\f\r
344 body{\r
345 +\f\r
346 part{ ID: 4, Content-type: multipart/alternative\r
347 +\f\r
348 part{ ID: 5, Content-type: text/html\r
349  Non-text part: text/html\r
350  \f\r
351 part}\r
352 +\f\r
353 part{ ID: 6, Content-type: text/plain\r
354 +This is an embedded message, with a multipart/alternative part.\r
355 +\f\r
356 part}\r
357 +\f\r
358 part}\r
359 +\f\r
360 body}\r
361  \f\r
362 part}\r
363  EOF\r
364  test_expect_equal_file OUTPUT EXPECTED\r
365  \r
366 -test_begin_subtest "--format=text --part=4, html part"\r
367 +test_begin_subtest "--format=text --part=4, rfc822's multipart"\r
368  notmuch show --format=text --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
369  cat <<EOF >EXPECTED\r
370 -\f\r
371 part{ ID: 4, Content-type: text/html\r
372 +\f\r
373 part{ ID: 4, Content-type: multipart/alternative\r
374 +\f\r
375 part{ ID: 5, Content-type: text/html\r
376  Non-text part: text/html\r
377  \f\r
378 part}\r
379 +\f\r
380 part{ ID: 6, Content-type: text/plain\r
381 +This is an embedded message, with a multipart/alternative part.\r
382 +\f\r
383 part}\r
384 +\f\r
385 part}\r
386  EOF\r
387  test_expect_equal_file OUTPUT EXPECTED\r
388  \r
389 -test_begin_subtest "--format=text --part=5, inline attachment"\r
390 +test_begin_subtest "--format=text --part=5, rfc822's html part"\r
391  notmuch show --format=text --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
392  cat <<EOF >EXPECTED\r
393 -\f\r
394 attachment{ ID: 5, Filename: attachment, Content-type: text/plain\r
395 -This is a text attachment.\r
396 -\f\r
397 attachment}\r
398 +\f\r
399 part{ ID: 5, Content-type: text/html\r
400 +Non-text part: text/html\r
401 +\f\r
402 part}\r
403  EOF\r
404  test_expect_equal_file OUTPUT EXPECTED\r
405  \r
406 -test_begin_subtest "--format=text --part=6, plain text part"\r
407 +test_begin_subtest "--format=text --part=6, rfc822's text part"\r
408  notmuch show --format=text --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
409  cat <<EOF >EXPECTED\r
410  \f\r
411 part{ ID: 6, Content-type: text/plain\r
412 +This is an embedded message, with a multipart/alternative part.\r
413 +\f\r
414 part}\r
415 +EOF\r
416 +test_expect_equal_file OUTPUT EXPECTED\r
417 +\r
418 +test_begin_subtest "--format=text --part=7, inline attachement"\r
419 +notmuch show --format=text --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
420 +cat <<EOF >EXPECTED\r
421 +\f\r
422 attachment{ ID: 7, Filename: attachment, Content-type: text/plain\r
423 +This is a text attachment.\r
424 +\f\r
425 attachment}\r
426 +EOF\r
427 +test_expect_equal_file OUTPUT EXPECTED\r
428 +\r
429 +test_begin_subtest "--format=text --part=8, plain text part"\r
430 +notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
431 +cat <<EOF >EXPECTED\r
432 +\f\r
433 part{ ID: 8, Content-type: text/plain\r
434  And this message is signed.\r
435  \r
436  -Carl\r
437 @@ -214,10 +304,10 @@ And this message is signed.\r
438  EOF\r
439  test_expect_equal_file OUTPUT EXPECTED\r
440  \r
441 -test_begin_subtest "--format=text --part=7, pgp signature (unverified)"\r
442 -notmuch show --format=text --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
443 +test_begin_subtest "--format=text --part=9, pgp signature (unverified)"\r
444 +notmuch show --format=text --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
445  cat <<EOF >EXPECTED\r
446 -\f\r
447 part{ ID: 7, Content-type: application/pgp-signature\r
448 +\f\r
449 part{ ID: 9, Content-type: application/pgp-signature\r
450  Non-text part: application/pgp-signature\r
451  \f\r
452 part}\r
453  EOF\r
454 @@ -228,48 +318,126 @@ test_expect_success \\r
455      "notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"\r
456  \r
457  test_begin_subtest "--format=json --part=0, full message"\r
458 -output=$(notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org')\r
459 -test_expect_equal "$output" \\r
460 -'{"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "filename": "'"${MAIL_DIR}/multipart"'", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Cc": "", "Bcc": "", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1, "content-type": "multipart/signed", "content": [{"id": 2, "content-type": "multipart/mixed", "content": [{"id": 3, "content-type": "message/rfc822", "content": [{"id": 4, "content-type": "text/html"}]}, {"id": 5, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, {"id": 6, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, {"id": 7, "content-type": "application/pgp-signature"}]}]}'\r
461 +notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
462 +echo >>OUTPUT # expect *no* newline at end of output\r
463 +cat <<EOF >EXPECTED\r
464 +\r
465 +{"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "filename": "${MAIL_DIR}/multipart", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Cc": "", "Bcc": "", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [\r
466 +{"id": 1, "content-type": "multipart/signed", "content": [\r
467 +{"id": 2, "content-type": "multipart/mixed", "content": [\r
468 +{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [\r
469 +{"id": 4, "content-type": "multipart/alternative", "content": [\r
470 +{"id": 5, "content-type": "text/html"}, \r
471 +{"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, \r
472 +{"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, \r
473 +{"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, \r
474 +{"id": 9, "content-type": "application/pgp-signature"}]}]}\r
475 +EOF\r
476 +test_expect_equal_file OUTPUT EXPECTED\r
477  \r
478  test_begin_subtest "--format=json --part=1, message body"\r
479 -output=$(notmuch show --format=json --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org')\r
480 -test_expect_equal "$output" \\r
481 -'{"id": 1, "content-type": "multipart/signed", "content": [{"id": 2, "content-type": "multipart/mixed", "content": [{"id": 3, "content-type": "message/rfc822", "content": [{"id": 4, "content-type": "text/html"}]}, {"id": 5, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, {"id": 6, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, {"id": 7, "content-type": "application/pgp-signature"}]}'\r
482 +notmuch show --format=json --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
483 +echo >>OUTPUT # expect *no* newline at end of output\r
484 +cat <<EOF >EXPECTED\r
485 +\r
486 +{"id": 1, "content-type": "multipart/signed", "content": [\r
487 +{"id": 2, "content-type": "multipart/mixed", "content": [\r
488 +{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [\r
489 +{"id": 4, "content-type": "multipart/alternative", "content": [\r
490 +{"id": 5, "content-type": "text/html"}, \r
491 +{"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, \r
492 +{"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, \r
493 +{"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, \r
494 +{"id": 9, "content-type": "application/pgp-signature"}]}\r
495 +EOF\r
496 +test_expect_equal_file OUTPUT EXPECTED\r
497  \r
498  test_begin_subtest "--format=json --part=2, multipart/mixed"\r
499 -output=$(notmuch show --format=json --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org')\r
500 -test_expect_equal "$output" \\r
501 -'{"id": 2, "content-type": "multipart/mixed", "content": [{"id": 3, "content-type": "message/rfc822", "content": [{"id": 4, "content-type": "text/html"}]}, {"id": 5, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, {"id": 6, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}'\r
502 -\r
503 -test_begin_subtest "--format=json --part=3, rfc822 multipart"\r
504 -output=$(notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org')\r
505 -test_expect_equal "$output" \\r
506 -'{"id": 3, "content-type": "message/rfc822", "content": [{"id": 4, "content-type": "text/html"}]}'\r
507 -\r
508 -test_begin_subtest "--format=json --part=4, html part"\r
509 -output=$(notmuch show --format=json --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org')\r
510 -test_expect_equal "$output" \\r
511 -'{"id": 4, "content-type": "text/html"}'\r
512 -\r
513 -test_begin_subtest "--format=json --part=5, inline attachment"\r
514 -output=$(notmuch show --format=json --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org')\r
515 -test_expect_equal "$output" \\r
516 -'{"id": 5, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}'\r
517 -\r
518 -test_begin_subtest "--format=json --part=6, plain text part"\r
519 -output=$(notmuch show --format=json --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org')\r
520 -test_expect_equal "$output" \\r
521 -'{"id": 6, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}'\r
522 -\r
523 -test_begin_subtest "--format=json --part=7, pgp signature (unverified)"\r
524 -output=$(notmuch show --format=json --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org')\r
525 -test_expect_equal "$output" \\r
526 -'{"id": 7, "content-type": "application/pgp-signature"}'\r
527 +notmuch show --format=json --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
528 +echo >>OUTPUT # expect *no* newline at end of output\r
529 +cat <<EOF >EXPECTED\r
530 +\r
531 +{"id": 2, "content-type": "multipart/mixed", "content": [\r
532 +{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [\r
533 +{"id": 4, "content-type": "multipart/alternative", "content": [\r
534 +{"id": 5, "content-type": "text/html"}, \r
535 +{"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, \r
536 +{"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, \r
537 +{"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}\r
538 +EOF\r
539 +test_expect_equal_file OUTPUT EXPECTED\r
540 +\r
541 +test_begin_subtest "--format=json --part=3, rfc822 part"\r
542 +notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
543 +echo >>OUTPUT # expect *no* newline at end of output\r
544 +cat <<EOF >EXPECTED\r
545 +\r
546 +{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [\r
547 +{"id": 4, "content-type": "multipart/alternative", "content": [\r
548 +{"id": 5, "content-type": "text/html"}, \r
549 +{"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}\r
550 +EOF\r
551 +test_expect_equal_file OUTPUT EXPECTED\r
552 +\r
553 +test_begin_subtest "--format=json --part=4, rfc822's multipart/alternative"\r
554 +notmuch show --format=json --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
555 +echo >>OUTPUT # expect *no* newline at end of output\r
556 +cat <<EOF >EXPECTED\r
557 +\r
558 +{"id": 4, "content-type": "multipart/alternative", "content": [\r
559 +{"id": 5, "content-type": "text/html"}, \r
560 +{"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}\r
561 +EOF\r
562 +test_expect_equal_file OUTPUT EXPECTED\r
563 +\r
564 +test_begin_subtest "--format=json --part=5, rfc822's html part"\r
565 +notmuch show --format=json --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
566 +echo >>OUTPUT # expect *no* newline at end of output\r
567 +cat <<EOF >EXPECTED\r
568 +\r
569 +{"id": 5, "content-type": "text/html"}\r
570 +EOF\r
571 +test_expect_equal_file OUTPUT EXPECTED\r
572 +\r
573 +test_begin_subtest "--format=json --part=6, rfc822's text part"\r
574 +notmuch show --format=json --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
575 +echo >>OUTPUT # expect *no* newline at end of output\r
576 +cat <<EOF >EXPECTED\r
577 +\r
578 +{"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}\r
579 +EOF\r
580 +test_expect_equal_file OUTPUT EXPECTED\r
581 +\r
582 +test_begin_subtest "--format=json --part=7, inline attachment"\r
583 +notmuch show --format=json --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
584 +echo >>OUTPUT # expect *no* newline at end of output\r
585 +cat <<EOF >EXPECTED\r
586 +\r
587 +{"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}\r
588 +EOF\r
589 +test_expect_equal_file OUTPUT EXPECTED\r
590 +\r
591 +test_begin_subtest "--format=json --part=8, plain text part"\r
592 +notmuch show --format=json --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
593 +echo >>OUTPUT # expect *no* newline at end of output\r
594 +cat <<EOF >EXPECTED\r
595 +\r
596 +{"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}\r
597 +EOF\r
598 +test_expect_equal_file OUTPUT EXPECTED\r
599 +\r
600 +test_begin_subtest "--format=json --part=9, pgp signature (unverified)"\r
601 +notmuch show --format=json --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
602 +echo >>OUTPUT # expect *no* newline at end of output\r
603 +cat <<EOF >EXPECTED\r
604 +\r
605 +{"id": 9, "content-type": "application/pgp-signature"}\r
606 +EOF\r
607 +test_expect_equal_file OUTPUT EXPECTED\r
608  \r
609  test_expect_success \\r
610 -    "--format=json --part=8, no part, expect error" \\r
611 -    "notmuch show --format=json --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"\r
612 +    "--format=json --part=10, no part, expect error" \\r
613 +    "notmuch show --format=json --part=10 'id:87liy5ap00.fsf@yoom.home.cworth.org'"\r
614  \r
615  test_begin_subtest "--format=raw"\r
616  notmuch show --format=raw 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
617 @@ -284,7 +452,13 @@ notmuch show --format=raw --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUT\r
618  # output should *not* include newline\r
619  echo >>OUTPUT\r
620  cat <<EOF >EXPECTED\r
621 -<p>This is an embedded message, with a single html part.</p>\r
622 +From: Carl Worth <cworth@cworth.org>\r
623 +To: cworth@cworth.org\r
624 +Subject: html message\r
625 +Date: Fri, 05 Jan 2001 15:42:57 +0000\r
626 +\r
627 +<p>This is an embedded message, with a multipart/alternative part.</p>\r
628 +This is an embedded message, with a multipart/alternative part.\r
629  This is a text attachment.\r
630  And this message is signed.\r
631  \r
632 @@ -302,7 +476,13 @@ test_expect_equal_file OUTPUT EXPECTED\r
633  test_begin_subtest "--format=raw --part=2, multipart/mixed"\r
634  notmuch show --format=raw --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
635  cat <<EOF >EXPECTED\r
636 -<p>This is an embedded message, with a single html part.</p>\r
637 +From: Carl Worth <cworth@cworth.org>\r
638 +To: cworth@cworth.org\r
639 +Subject: html message\r
640 +Date: Fri, 05 Jan 2001 15:42:57 +0000\r
641 +\r
642 +<p>This is an embedded message, with a multipart/alternative part.</p>\r
643 +This is an embedded message, with a multipart/alternative part.\r
644  This is a text attachment.\r
645  And this message is signed.\r
646  \r
647 @@ -310,29 +490,41 @@ And this message is signed.\r
648  EOF\r
649  test_expect_equal_file OUTPUT EXPECTED\r
650  \r
651 -test_begin_subtest "--format=raw --part=3, rfc822 multipart"\r
652 +test_begin_subtest "--format=raw --part=3, rfc822 part"\r
653  notmuch show --format=raw --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
654 +test_expect_equal_file OUTPUT embedded_message\r
655 +\r
656 +test_begin_subtest "--format=raw --part=4, rfc822's html part"\r
657 +notmuch show --format=raw --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
658  cat <<EOF >EXPECTED\r
659 -<p>This is an embedded message, with a single html part.</p>\r
660 +<p>This is an embedded message, with a multipart/alternative part.</p>\r
661 +This is an embedded message, with a multipart/alternative part.\r
662  EOF\r
663  test_expect_equal_file OUTPUT EXPECTED\r
664  \r
665 -test_begin_subtest "--format=raw --part=4, html part"\r
666 -notmuch show --format=raw --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
667 +test_begin_subtest "--format=raw --part=5, rfc822's html part"\r
668 +notmuch show --format=raw --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
669  cat <<EOF >EXPECTED\r
670 -<p>This is an embedded message, with a single html part.</p>\r
671 +<p>This is an embedded message, with a multipart/alternative part.</p>\r
672  EOF\r
673  test_expect_equal_file OUTPUT EXPECTED\r
674  \r
675 -test_begin_subtest "--format=raw --part=5, inline attachment"\r
676 -notmuch show --format=raw --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
677 +test_begin_subtest "--format=raw --part=6, rfc822's text part"\r
678 +notmuch show --format=raw --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
679 +cat <<EOF >EXPECTED\r
680 +This is an embedded message, with a multipart/alternative part.\r
681 +EOF\r
682 +test_expect_equal_file OUTPUT EXPECTED\r
683 +\r
684 +test_begin_subtest "--format=raw --part=7, inline attachment"\r
685 +notmuch show --format=raw --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
686  cat <<EOF >EXPECTED\r
687  This is a text attachment.\r
688  EOF\r
689  test_expect_equal_file OUTPUT EXPECTED\r
690  \r
691 -test_begin_subtest "--format=raw --part=6, plain text part"\r
692 -notmuch show --format=raw --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
693 +test_begin_subtest "--format=raw --part=8, plain text part"\r
694 +notmuch show --format=raw --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
695  cat <<EOF >EXPECTED\r
696  And this message is signed.\r
697  \r
698 @@ -340,8 +532,8 @@ And this message is signed.\r
699  EOF\r
700  test_expect_equal_file OUTPUT EXPECTED\r
701  \r
702 -test_begin_subtest "--format=raw --part=7, pgp signature (unverified)"\r
703 -notmuch show --format=raw --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
704 +test_begin_subtest "--format=raw --part=9, pgp signature (unverified)"\r
705 +notmuch show --format=raw --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
706  # output should *not* include newline\r
707  echo >>OUTPUT\r
708  cat <<EOF >EXPECTED\r
709 @@ -356,7 +548,7 @@ EOF\r
710  test_expect_equal_file OUTPUT EXPECTED\r
711  \r
712  test_expect_success \\r
713 -    "--format=raw --part=8, no part, expect error" \\r
714 +    "--format=raw --part=10, no part, expect error" \\r
715      "notmuch show --format=raw --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"\r
716  \r
717  test_begin_subtest "--format=mbox"\r
718 @@ -383,8 +575,14 @@ References: <87liy5ap00.fsf@yoom.home.cworth.org>\r
719  On Fri, 05 Jan 2001 15:43:57 +0000, Carl Worth <cworth@cworth.org> wrote:\r
720  Non-text part: multipart/signed\r
721  Non-text part: multipart/mixed\r
722 -Non-text part: message/rfc822\r
723 +> From: Carl Worth <cworth@cworth.org>\r
724 +> To: cworth@cworth.org\r
725 +> Subject: html message\r
726 +> Date: Fri, 05 Jan 2001 15:42:57 +0000\r
727 +>\r
728 +Non-text part: multipart/alternative\r
729  Non-text part: text/html\r
730 +> This is an embedded message, with a multipart/alternative part.\r
731  > This is a text attachment.\r
732  > And this message is signed.\r
733  > \r
734 -- \r
735 1.7.5.4\r
736 \r