From 513a36d105995c327c23fec5f60ea70c65b986dd Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 14 Dec 2013 22:39:54 +0800 Subject: test: add emacs_fcc_message that does not use smtp-dummy Most of the tests previously using emacs_deliver_message do not use the actual transmitted message, so we replace it with a simpler (and presumably more reliable function) that only saves (and indexes) an fcc copy of the message. --- test/test-lib.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/test-lib.sh') diff --git a/test/test-lib.sh b/test/test-lib.sh index 53cb9475..be0c133b 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -470,6 +470,36 @@ emacs_deliver_message () notmuch new >/dev/null } +# Pretend to deliver a message with emacs. Really save it to a file +# and add it to the database +# +# Uses emacs to generate and deliver a message to the mail store. +# Accepts arbitrary extra emacs/elisp functions to modify the message +# before sending, which is useful to doing things like attaching files +# to the message and encrypting/signing. +emacs_fcc_message () +{ + local subject="$1" + local body="$2" + shift 2 + # before we can send a message, we have to prepare the FCC maildir + mkdir -p "$MAIL_DIR"/sent/{cur,new,tmp} + + test_emacs \ + "(let ((message-send-mail-function (lambda () t)) + (mail-host-address \"example.com\")) + (notmuch-mua-mail) + (message-goto-to) + (insert \"test_suite@notmuchmail.org\nDate: 01 Jan 2000 12:00:00 -0000\") + (message-goto-subject) + (insert \"${subject}\") + (message-goto-body) + (insert \"${body}\") + $@ + (message-send-and-exit))" || return 1 + notmuch new >/dev/null +} + # Generate a corpus of email and add it to the database. # # This corpus is fixed, (it happens to be 50 messages from early in -- cgit v1.2.3