emacs: postpone a message
[notmuch] / test / T630-emacs-draft.sh
1 #!/usr/bin/env bash
2 test_description="Emacs Draft Handling"
3 . ./test-lib.sh || exit 1
4
5 add_email_corpus
6
7 notmuch config set search.exclude_tags deleted
8
9 test_begin_subtest "Saving a draft indexes it"
10 test_emacs '(notmuch-mua-mail)
11             (message-goto-subject)
12             (insert "draft-test-0001")
13             (notmuch-draft-save)
14             (test-output)'
15 count1=$(notmuch count tag:draft)
16 count2=$(notmuch count subject:draft-test-0001)
17 test_expect_equal "$count1=$count2" "1=1"
18
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")
23             (notmuch-draft-save)
24             (notmuch-draft-save)
25             (test-output)'
26 count1=$(notmuch count tag:draft)
27 count2=$(notmuch count subject:draft-test-0002)
28
29 test_expect_equal "$count1,$count2" "2,1"
30
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             (mml-secure-message-sign)
36             (notmuch-draft-save)
37             (test-output)'
38 header_count=$(notmuch show --format=raw subject:draft-test-0003 | grep -c ^X-Notmuch-Emacs-Secure)
39 body_count=$(notmuch notmuch show --format=raw subject:draft-test-0003 | grep -c '^\<#secure')
40 test_expect_equal "$header_count,$body_count" "1,0"
41
42 test_done