--- test/T720-emacs-attachment-warnings.sh | 36 ++++++++++++++++++++++++++++++++++ test/emacs-attachment-test.el | 25 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100755 test/T720-emacs-attachment-warnings.sh create mode 100644 test/emacs-attachment-test.el diff --git a/test/T720-emacs-attachment-warnings.sh b/test/T720-emacs-attachment-warnings.sh new file mode 100755 index 00000000..19bb2338 --- /dev/null +++ b/test/T720-emacs-attachment-warnings.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +test_description="emacs attachment warnings" +. $(dirname "$0")/test-lib.sh || exit 1 + +declare -a okays=( + "nothing to see" + "attachment\n<#part filename=foo />" + "<#part filename=foo/>" +) + +declare -a not_okays=( + "attachment" +) + +echo "okay" > EXPECTED +for okay in "${okays[@]}"; do + test_begin_subtest "Check okay" + test_emacs ' +(load-library "emacs-attachment-test.el") +(single-test "'"$okay"'") +(test-output)' + test_expect_equal_file EXPECTED OUTPUT +done + +echo "not okay!" > EXPECTED +for not_okay in "${not_okays[@]}"; do + test_begin_subtest "Check not_okay" + test_emacs ' +(load-library "emacs-attachment-test.el") +(single-test "'"$not_okay"'") +(test-output)' + test_expect_equal_file EXPECTED OUTPUT +done + +test_done diff --git a/test/emacs-attachment-test.el b/test/emacs-attachment-test.el new file mode 100644 index 00000000..604a16e5 --- /dev/null +++ b/test/emacs-attachment-test.el @@ -0,0 +1,25 @@ +(defun single-test (bodytext) + (set-buffer (get-buffer-create "result")) + (delete-region (point-min) (point-max)) + (insert (save-excursion + (single-test1 bodytext)) + "\n")) + +(defun single-test1 (bodytext) + "Test `notmuch-mua-attachment-check' using a message consisting of BODYTEXT. + +Return 'okay' if the message would be sent, otherwise 'not +okay!'" + (notmuch-mua-mail) + (message-goto-body) + (insert bodytext) + (prog1 + (condition-case detail + ;; Force `y-or-n-p' to always return `nil', as if the user + ;; pressed "n". + (letf (((symbol-function 'y-or-n-p) (lambda (&rest args) nil))) + (notmuch-mua-attachment-check) + "okay") + ('error "not okay!")) + (set-buffer-modified-p nil) + (kill-buffer (current-buffer)))) -- 2.11.0 _______________________________________________ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch