2d066ed439d44d297eb92fc6995edb44d92a556c
[notmuch] / test / emacs
1 #!/usr/bin/env bash
2
3 test_description="emacs interface"
4 . test-lib.sh
5
6 EXPECTED=$TEST_DIRECTORY/emacs.expected-output
7
8 add_email_corpus
9
10 test_begin_subtest "Basic notmuch-hello view in emacs"
11 test_emacs '(notmuch-hello)
12             (test-output)'
13 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello
14
15 test_begin_subtest "Saved search with 0 results"
16 test_emacs '(let ((notmuch-show-empty-saved-searches t)
17                   (notmuch-saved-searches
18                    '\''(("inbox" . "tag:inbox")
19                         ("unread" . "tag:unread")
20                         ("empty" . "tag:doesnotexist"))))
21               (notmuch-hello)
22               (test-output))'
23 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-with-empty
24
25 test_begin_subtest "No saved searches displayed (all with 0 results)"
26 test_emacs '(let ((notmuch-saved-searches
27                    '\''(("empty" . "tag:doesnotexist"))))
28               (notmuch-hello)
29               (test-output))'
30 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-searches
31
32 test_begin_subtest "Basic notmuch-search view in emacs"
33 test_emacs '(notmuch-search "tag:inbox")
34             (notmuch-test-wait)
35             (test-output)'
36 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
37
38 test_begin_subtest "Navigation of notmuch-hello to search results"
39 test_emacs '(notmuch-hello)
40             (goto-char (point-min))
41             (re-search-forward "inbox")
42             (widget-button-press (point))
43             (notmuch-test-wait)
44             (test-output)'
45 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox
46
47 test_begin_subtest "Basic notmuch-show view in emacs"
48 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
49 test_emacs "(notmuch-show \"$maildir_storage_thread\")
50             (test-output)"
51 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
52
53 test_begin_subtest "Basic notmuch-show view in emacs default indentation"
54 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
55 test_emacs "(let ((notmuch-show-indent-messages-width 1))
56               (notmuch-show \"$maildir_storage_thread\")
57               (test-output))"
58 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
59
60 test_begin_subtest "Basic notmuch-show view in emacs without indentation"
61 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
62 test_emacs "(let ((notmuch-show-indent-messages-width 0))
63               (notmuch-show \"$maildir_storage_thread\")
64               (test-output))"
65 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage-without-indentation
66
67 test_begin_subtest "Basic notmuch-show view in emacs with fourfold indentation"
68 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
69 test_emacs "(let ((notmuch-show-indent-messages-width 4))
70               (notmuch-show \"$maildir_storage_thread\")
71               (test-output))"
72 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage-with-fourfold-indentation
73
74 test_begin_subtest "notmuch-show for message with invalid From"
75 add_message "[subject]=\"message-with-invalid-from\"" \
76             "[from]=\"\\\"Invalid \\\" From\\\" <test_suite@notmuchmail.org>\""
77 thread=$(notmuch search --output=threads subject:message-with-invalid-from)
78 test_emacs "(notmuch-show \"$thread\")
79             (test-output)"
80 cat <<EOF >EXPECTED
81 "Invalid " From" <test_suite@notmuchmail.org> (2001-01-05) (inbox)
82 Subject: message-with-invalid-from
83 To: Notmuch Test Suite <test_suite@notmuchmail.org>
84 Date: Tue, 05 Jan 2001 15:43:57 -0000
85
86 This is just a test message (#1)
87 EOF
88 test_expect_equal_file OUTPUT EXPECTED
89
90 test_begin_subtest "Navigation of notmuch-search to thread view"
91 test_emacs '(notmuch-search "tag:inbox")
92             (notmuch-test-wait)
93             (goto-char (point-min))
94             (re-search-forward "Working with Maildir")
95             (notmuch-search-show-thread)
96             (notmuch-test-wait)
97             (test-output)'
98 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
99
100 test_begin_subtest "Add tag from search view"
101 os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com)
102 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
103             (notmuch-test-wait)
104             (notmuch-search-add-tag \"tag-from-search-view\")"
105 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
106 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-search-view unread)"
107
108 test_begin_subtest "Remove tag from search view"
109 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
110             (notmuch-test-wait)
111             (notmuch-search-remove-tag \"tag-from-search-view\")"
112 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
113 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)"
114
115 test_begin_subtest "Add tag from notmuch-show view"
116 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
117             (notmuch-show-add-tag \"tag-from-show-view\")"
118 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
119 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-show-view unread)"
120
121 test_begin_subtest "Remove tag from notmuch-show view"
122 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
123             (notmuch-show-remove-tag \"tag-from-show-view\")"
124 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
125 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)"
126
127 test_begin_subtest "Message with .. in Message-Id:"
128 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
129 test_emacs '(notmuch-search "id:\"123..456@example\"")
130             (notmuch-test-wait)
131             (notmuch-search-add-tag "search-add")
132             (notmuch-search-add-tag "search-remove")
133             (notmuch-search-remove-tag "search-remove")
134             (notmuch-show "id:\"123..456@example\"")
135             (notmuch-test-wait)
136             (notmuch-show-add-tag "show-add")
137             (notmuch-show-add-tag "show-remove")
138             (notmuch-show-remove-tag "show-remove")'
139 output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize)
140 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
141
142 test_begin_subtest "Sending a message via (fake) SMTP"
143 emacs_deliver_message \
144     'Testing message sent via SMTP' \
145     'This is a test that messages are sent via SMTP' \
146     '(message-goto-to)
147      (kill-whole-line)
148      (insert "To: user@example.com\n")'
149 sed \
150     -e s',^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' \
151     -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' < sent_message >OUTPUT
152 cat <<EOF >EXPECTED
153 From: Notmuch Test Suite <test_suite@notmuchmail.org>
154 To: user@example.com
155 Subject: Testing message sent via SMTP
156 Date: 01 Jan 2000 12:00:00 -0000
157 User-Agent: Notmuch/XXX Emacs/XXX
158 Message-ID: <XXX>
159 MIME-Version: 1.0
160 Content-Type: text/plain; charset=us-ascii
161
162 This is a test that messages are sent via SMTP
163 EOF
164 test_expect_equal_file OUTPUT EXPECTED
165
166 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
167 notmuch new > /dev/null
168 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
169 test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
170
171 test_begin_subtest "notmuch-fcc-dirs set to nil"
172 test_emacs "(let ((notmuch-fcc-dirs nil))
173               (notmuch-mua-mail)
174               (test-output))"
175 cat <<EOF >EXPECTED
176 From: Notmuch Test Suite <test_suite@notmuchmail.org>
177 To: 
178 Subject: 
179 --text follows this line--
180 EOF
181 test_expect_equal_file OUTPUT EXPECTED
182
183 # Make another FCC maildir specific for the next test
184 mkdir -p mail/sent-string/cur
185 mkdir -p mail/sent-string/new
186 mkdir -p mail/sent-string/tmp
187
188 test_begin_subtest "notmuch-fcc-dirs set to a string"
189 test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))
190               (notmuch-mua-mail)
191               (test-output))"
192 cat <<EOF >EXPECTED
193 From: Notmuch Test Suite <test_suite@notmuchmail.org>
194 To: 
195 Subject: 
196 Fcc: ${MAIL_DIR}/sent-string
197 --text follows this line--
198 EOF
199 test_expect_equal_file OUTPUT EXPECTED
200
201 # Make more FCC maildirs specific for the next test
202 mkdir -p mail/sent-list-match/cur
203 mkdir -p mail/sent-list-match/new
204 mkdir -p mail/sent-list-match/tmp
205 mkdir -p mail/failure/cur
206 mkdir -p mail/failure/new
207 mkdir -p mail/failure/tmp
208
209 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
210 test_emacs "(let ((notmuch-fcc-dirs
211                    '((\"notmuchmail.org\" . \"sent-list-match\")
212                      (\".*\" . \"failure\"))))
213               (notmuch-mua-mail)
214               (test-output))"
215 cat <<EOF >EXPECTED
216 From: Notmuch Test Suite <test_suite@notmuchmail.org>
217 To: 
218 Subject: 
219 Fcc: ${MAIL_DIR}/sent-list-match
220 --text follows this line--
221 EOF
222 test_expect_equal_file OUTPUT EXPECTED
223
224 # Make another FCC maildir specific for the next test
225 mkdir -p mail/sent-list-catch-all/cur
226 mkdir -p mail/sent-list-catch-all/new
227 mkdir -p mail/sent-list-catch-all/tmp
228  
229 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
230 test_emacs "(let ((notmuch-fcc-dirs
231                    '((\"example.com\" . \"failure\")
232                      (\".*\" . \"sent-list-catch-all\"))))
233               (notmuch-mua-mail)
234               (test-output))"
235 cat <<EOF >EXPECTED
236 From: Notmuch Test Suite <test_suite@notmuchmail.org>
237 To: 
238 Subject: 
239 Fcc: ${MAIL_DIR}/sent-list-catch-all
240 --text follows this line--
241 EOF
242 test_expect_equal_file OUTPUT EXPECTED
243
244 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
245 test_emacs "(let ((notmuch-fcc-dirs
246                    '((\"example.com\" . \"failure\")
247                      (\"nomatchhere.net\" . \"failure\"))))
248               (notmuch-mua-mail)
249               (test-output))"
250 cat <<EOF >EXPECTED
251 From: Notmuch Test Suite <test_suite@notmuchmail.org>
252 To: 
253 Subject: 
254 --text follows this line--
255 EOF
256 test_expect_equal_file OUTPUT EXPECTED
257
258 test_begin_subtest "Reply within emacs"
259 test_emacs '(notmuch-search "subject:\"testing message sent via SMTP\"")
260             (notmuch-test-wait)
261             (notmuch-search-reply-to-thread)
262             (test-output)'
263 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
264 cat <<EOF >EXPECTED
265 From: Notmuch Test Suite <test_suite@notmuchmail.org>
266 To: user@example.com
267 Subject: Re: Testing message sent via SMTP
268 In-Reply-To: <XXX>
269 Fcc: $(pwd)/mail/sent
270 --text follows this line--
271 On 01 Jan 2000 12:00:00 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
272 > This is a test that messages are sent via SMTP
273 EOF
274 test_expect_equal_file OUTPUT EXPECTED
275
276 test_begin_subtest "Quote MML tags in reply"
277 message_id='test-emacs-mml-quoting@message.id'
278 add_message [id]="$message_id" \
279             "[subject]='$test_subtest_name'" \
280             '[body]="<#part disposition=inline>"'
281 test_emacs "(notmuch-show \"id:$message_id\")
282               (notmuch-show-reply)
283               (test-output)"
284 cat <<EOF >EXPECTED
285 From: Notmuch Test Suite <test_suite@notmuchmail.org>
286 To: 
287 Subject: Re: Quote MML tags in reply
288 In-Reply-To: <test-emacs-mml-quoting@message.id>
289 Fcc: ${MAIL_DIR}/sent
290 --text follows this line--
291 On Tue, 05 Jan 2001 15:43:57 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
292 > <#!part disposition=inline>
293 EOF
294 test_expect_equal_file OUTPUT EXPECTED
295
296 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
297 # save as archive to test that Emacs does not re-compress .gz
298 test_emacs '(let ((standard-input "\"attachment1.gz\""))
299               (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
300               (notmuch-show-save-attachments))'
301 test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
302
303 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
304 # save as archive to test that Emacs does not re-compress .gz
305 test_emacs '(let ((standard-input "\"attachment2.gz\""))
306               (notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))'
307 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
308
309 test_begin_subtest "View raw message within emacs"
310 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
311             (notmuch-show-view-raw-message)
312             (test-output)'
313 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
314
315 test_begin_subtest "Hiding/showing signature in notmuch-show view"
316 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
317 test_emacs "(notmuch-show \"$maildir_storage_thread\")
318             (search-forward \"Click/Enter to show.\")
319             (button-activate (button-at (point)))
320             (search-backward \"Click/Enter to hide.\")
321             (button-activate (button-at (point)))
322             (test-output)"
323 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
324
325 test_begin_subtest "Detection and hiding of top-post quoting of message"
326 add_message '[subject]="The problem with top-posting"' \
327             [id]=top-post-target \
328             '[body]="A: Because it messes up the order in which people normally read text.
329 Q: Why is top-posting such a bad thing?
330 A: Top-posting.
331 Q: What is the most annoying thing in e-mail?"'
332 add_message '[from]="Top Poster <top@poster.com>"' \
333             [in-reply-to]=top-post-target \
334             [references]=top-post-target \
335             '[subject]="Re: The problem with top-posting"' \
336             '[body]="Thanks for the advice! I will be sure to put it to good use.
337
338 -Top Poster
339
340 ----- Original Message -----
341 From: Notmuch Test Suite <test_suite@notmuchmail.org>
342 To: Notmuch Test Suite <test_suite@notmuchmai.org>
343 Sent: Tue, 05 Jan 2001 15:43:57 -0000
344 Subject: The problem with top-posting
345
346 Q: Why is top-posting such a bad thing?
347 A: Top-posting.
348 Q: What is the most annoying thing in e-mail?"'
349 test_emacs "(notmuch-show \"top-posting\")
350             (test-visible-output)"
351 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
352 Subject: The problem with top-posting
353 To: Notmuch Test Suite <test_suite@notmuchmail.org>
354 Date: Tue, 05 Jan 2001 15:43:57 -0000
355
356 A: Because it messes up the order in which people normally read text.
357 Q: Why is top-posting such a bad thing?
358 A: Top-posting.
359 Q: What is the most annoying thing in e-mail?
360 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
361 Subject: Re: The problem with top-posting
362 To: Notmuch Test Suite <test_suite@notmuchmail.org>
363 Date: Tue, 05 Jan 2001 15:43:57 -0000
364
365 Thanks for the advice! I will be sure to put it to good use.
366
367 -Top Poster
368
369 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
370 test_expect_equal_file OUTPUT EXPECTED
371
372 test_begin_subtest "Hiding message in notmuch-show view"
373 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
374             (notmuch-show-toggle-message)
375             (test-visible-output)'
376 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
377
378 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
379 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
380             (search-forward "Click/Enter to show.")
381             (button-activate (button-at (point)))
382             (notmuch-show-toggle-message)
383             (test-visible-output)'
384 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
385
386 test_begin_subtest "Stashing in notmuch-show"
387 add_message '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
388     '[from]="Some One <someone@somewhere.org>"' \
389     '[to]="Some One Else <notsomeone@somewhere.org>"' \
390     '[cc]="Notmuch <notmuch@notmuchmail.org>"' \
391     '[subject]="Stash my stashables"' \
392     '[id]="bought"' \
393     '[body]="Unable to stash body. Where did you get it in the first place?!?"'
394 notmuch tag +stashtest id:${gen_msg_id}
395 test_emacs '(notmuch-show "id:\"bought\"")
396         (notmuch-show-stash-date)
397         (notmuch-show-stash-from)
398         (notmuch-show-stash-to)
399         (notmuch-show-stash-cc)
400         (notmuch-show-stash-subject)
401         (notmuch-show-stash-message-id)
402         (notmuch-show-stash-message-id-stripped)
403         (notmuch-show-stash-tags)
404         (notmuch-show-stash-filename)
405         (switch-to-buffer
406           (generate-new-buffer "*test-stashing*"))
407         (dotimes (i 9)
408           (yank)
409           (insert "\n")
410           (rotate-yank-pointer 1))
411         (reverse-region (point-min) (point-max))
412             (test-output)'
413 cat <<EOF >EXPECTED
414 Sat, 01 Jan 2000 12:00:00 -0000
415 Some One <someone@somewhere.org>
416 Some One Else <notsomeone@somewhere.org>
417 Notmuch <notmuch@notmuchmail.org>
418 Stash my stashables
419 id:"bought"
420 bought
421 inbox,stashtest
422 ${gen_msg_filename}
423 EOF
424 test_expect_equal_file OUTPUT EXPECTED
425
426 test_begin_subtest "Stashing in notmuch-search"
427 test_emacs '(notmuch-search "id:\"bought\"")
428         (notmuch-test-wait)
429         (notmuch-search-stash-thread-id)
430         (switch-to-buffer
431           (generate-new-buffer "*test-stashing*"))
432         (yank)
433             (test-output)'
434 sed -i -e 's/^thread:.*$/thread:XXX/' OUTPUT
435 test_expect_equal "$(cat OUTPUT)" "thread:XXX"
436
437 test_begin_subtest 'notmuch-show-advance-and-archive with invisible signature'
438 message1='id:20091118010116.GC25380@dottiness.seas.harvard.edu'
439 message2='id:1258491078-29658-1-git-send-email-dottedmag@dottedmag.net'
440 test_emacs "(notmuch-search \"$message1 or $message2\")
441             (notmuch-test-wait)
442             (notmuch-search-show-thread)
443             (goto-char (point-max))
444             (redisplay)
445             (notmuch-show-advance-and-archive)
446             (test-output)"
447 test_emacs "(notmuch-show \"$message2\")
448             (test-output \"EXPECTED\")"
449 test_expect_equal_file OUTPUT EXPECTED
450
451 test_begin_subtest "Refresh show buffer"
452 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
453             (test-visible-output "EXPECTED")
454             (notmuch-show-refresh-view)
455             (test-visible-output)'
456 test_expect_equal_file OUTPUT EXPECTED
457
458 test_begin_subtest "Refresh modified show buffer"
459 test_subtest_known_broken
460 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
461             (notmuch-show-toggle-message)
462             (notmuch-show-next-message)
463             (notmuch-show-toggle-message)
464             (test-visible-output "EXPECTED")
465             (notmuch-show-refresh-view)
466             (test-visible-output)'
467 test_expect_equal_file OUTPUT EXPECTED
468
469 test_begin_subtest "Do not call notmuch for non-inlinable application/mpeg parts"
470 id='message-with-application/mpeg-attachment@notmuchmail.org'
471 emacs_deliver_message \
472     'Message with application/mpeg attachment' \
473     '' \
474     "(message-goto-eoh)
475      (insert \"Message-ID: <$id>\n\")
476      (message-goto-body)
477      (mml-insert-part \"application/mpeg\")
478      (insert \"a fake mp3 file\")"
479 notmuch_counter_reset
480 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
481               (notmuch-show \"id:$id\"))"
482 test_expect_equal $(notmuch_counter_value) 1
483
484 test_begin_subtest "Do not call notmuch for non-inlinable audio/mpeg parts"
485 id='message-with-audio/mpeg-attachment@notmuchmail.org'
486 emacs_deliver_message \
487     'Message with audio/mpeg attachment' \
488     '' \
489     "(message-goto-eoh)
490      (insert \"Message-ID: <$id>\n\")
491      (message-goto-body)
492      (mml-insert-part \"audio/mpeg\")
493      (insert \"a fake mp3 file\")"
494 notmuch_counter_reset
495 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
496               (notmuch-show \"id:$id\"))"
497 test_expect_equal $(notmuch_counter_value) 1
498
499 test_begin_subtest "notmuch-hello-mode hook is called"
500 counter=$(test_emacs \
501     '(let ((notmuch-hello-mode-hook-counter 0))
502        (kill-buffer "*notmuch-hello*")
503        (notmuch-hello)
504        notmuch-hello-mode-hook-counter)'
505 )
506 test_expect_equal "$counter" 1
507
508 test_begin_subtest "notmuch-hello-mode hook is not called on updates"
509 counter=$(test_emacs \
510     '(let ((notmuch-hello-mode-hook-counter 0))
511        (kill-buffer "*notmuch-hello*")
512        (notmuch-hello)
513        (notmuch-hello-update)
514        notmuch-hello-mode-hook-counter)'
515 )
516 test_expect_equal "$counter" 1
517
518 test_begin_subtest "notmuch-hello-refresh hook is called"
519 counter=$(test_emacs \
520     '(let ((notmuch-hello-refresh-hook-counter 0))
521        (kill-buffer "*notmuch-hello*")
522        (notmuch-hello)
523        notmuch-hello-refresh-hook-counter)'
524 )
525 test_expect_equal "$counter" 1
526
527 test_begin_subtest "notmuch-hello-refresh hook is called on updates"
528 counter=$(test_emacs \
529     '(let ((notmuch-hello-refresh-hook-counter 0))
530        (kill-buffer "*notmuch-hello*")
531        (notmuch-hello)
532        (notmuch-hello-update)
533        notmuch-hello-refresh-hook-counter)'
534 )
535 test_expect_equal "$counter" 2
536
537 test_done