* test/emacs-search: - New subtest "notmuch-search: change tags of all matching messages": `notmuch-search-tag-all' (bound to "*") adds and removes tags to/from all messages which match the query used to populate the current search buffer. ---
Moved to a separate file to prevent a merge conflict when applied in conjunction with the patches listed @ id:"877gz4dnl2.fsf at praet.org". test/emacs-search | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ test/notmuch-test | 1 + 2 files changed, 49 insertions(+), 0 deletions(-) create mode 100755 test/emacs-search diff --git a/test/emacs-search b/test/emacs-search new file mode 100755 index 0000000..1cd8a89 --- /dev/null +++ b/test/emacs-search @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +test_description="Emacs notmuch-search-mode" +. test-lib.sh + +EXPECTED=$TEST_DIRECTORY/emacs-show.expected-output + +add_email_corpus + + +test_begin_subtest "notmuch-search: change tags of all matching messages" +old_tag="inbox" +new_tag="xobni" +filter="AND from:cworth" + +# Get initial tag counts and prevent false positives/negatives +old_tag_count_1=$(notmuch count tag:"${old_tag}" "${filter}") +new_tag_count_1=$(notmuch count tag:"${new_tag}" "${filter}") +test "${old_tag_count_1}" = "0" && old_tag_count_1="Need >0 matches!" +test "${new_tag_count_1}" = "0" || new_tag_count_1="Need 0 matches!" + +# Change tags of all matching messages and get tag counts +test_emacs "(notmuch-search \"tag:${old_tag} ${filter}\") + (notmuch-test-wait) + (notmuch-search-tag-all \"-${old_tag}\" \"+${new_tag}\")" +old_tag_count_2=$(notmuch count tag:"${old_tag}" "${filter}") +new_tag_count_2=$(notmuch count tag:"${new_tag}" "${filter}") + +# Revert tag changes and get tag counts +test_emacs "(notmuch-search \"tag:${new_tag} ${filter}\") + (notmuch-test-wait) + (notmuch-search-tag-all \"+${old_tag}\" \"-${new_tag}\")" +old_tag_count_3=$(notmuch count tag:"${old_tag}" "${filter}") +new_tag_count_3=$(notmuch count tag:"${new_tag}" "${filter}") + +# ... and verify the results +output=" +before: old:${old_tag_count_1} new:${new_tag_count_1} +after: old:${old_tag_count_2} new:${new_tag_count_2} +restored: old:${old_tag_count_3} new:${new_tag_count_3}" +expected=" +before: old:${old_tag_count_1} new:0 +after: old:0 new:${old_tag_count_1} +restored: old:${old_tag_count_1} new:0" +test_expect_equal "$output" "$expected" + + +test_done diff --git a/test/notmuch-test b/test/notmuch-test index e14d34e..81d0d7f 100755 --- a/test/notmuch-test +++ b/test/notmuch-test @@ -54,6 +54,7 @@ TESTS=" argument-parsing emacs-test-functions emacs-address-cleaning + emacs-search emacs-show " TESTS=${NOTMUCH_TESTS:=$TESTS} -- 1.7.8.1