2 test_description="Emacs Draft Handling"
3 . $(dirname "$0")/test-lib.sh || exit 1
7 notmuch config set search.exclude_tags deleted
9 test_begin_subtest "Saving a draft indexes it"
10 test_emacs '(notmuch-mua-mail)
11 (message-goto-subject)
12 (insert "draft-test-0001")
15 count1=$(notmuch count tag:draft)
16 count2=$(notmuch count subject:draft-test-0001)
17 test_expect_equal "$count1=$count2" "1=1"
19 test_begin_subtest "Saving a draft tags previous draft as deleted"
20 test_emacs '(notmuch-mua-mail)
21 (message-goto-subject)
22 (insert "draft-test-0002")
26 count1=$(notmuch count tag:draft)
27 count2=$(notmuch count subject:draft-test-0002)
29 test_expect_equal "$count1,$count2" "2,1"
31 test_begin_subtest "Saving a signed draft adds header"
32 test_emacs '(notmuch-mua-mail)
33 (message-goto-subject)
34 (insert "draft-test-0003")
35 ;; We would use (mml-secure-message-sign) but on emacs23
36 ;; that only signs the part, not the whole message.
37 (mml-secure-message mml-secure-method '\''sign)
40 header_count=$(notmuch show --format=raw subject:draft-test-0003 | grep -c ^X-Notmuch-Emacs-Secure)
41 body_count=$(notmuch notmuch show --format=raw subject:draft-test-0003 | grep -c '^\<#secure')
42 test_expect_equal "$header_count,$body_count" "1,0"
44 test_begin_subtest "Refusing to save an encrypted draft"
45 test_emacs '(notmuch-mua-mail)
46 (message-goto-subject)
47 (insert "draft-test-0004")
48 (mml-secure-message-sign-encrypt)
49 (let ((notmuch-draft-save-plaintext nil))
52 count1=$(notmuch count tag:draft)
53 count2=$(notmuch count subject:draft-test-0004)
55 test_expect_equal "$count1,$count2" "3,0"
57 test_begin_subtest "Resuming a signed draft"
59 test_emacs '(notmuch-show "subject:draft-test-0003")
60 (notmuch-show-resume-message)
62 notmuch_dir_sanitize OUTPUT > OUTPUT.clean
63 cat <<EOF | notmuch_dir_sanitize >EXPECTED
64 From: Notmuch Test Suite <test_suite@notmuchmail.org>
66 Subject: draft-test-0003
68 --text follows this line--
69 <#secure method=pgpmime mode=sign>
71 test_expect_equal_file EXPECTED OUTPUT.clean