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