[PATCH v2 4/4] test: emacs: new test "notmuch-search: change tags of all matching messages"
Pieter Praet
pieter at praet.org
Sun Feb 19 12:38:28 PST 2012
`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.
---
test/emacs | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/test/emacs b/test/emacs
index b0fb760..1db8540 100755
--- a/test/emacs
+++ b/test/emacs
@@ -124,6 +124,38 @@ test_emacs "(notmuch-show \"$os_x_darwin_thread\")
output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)"
+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 1+ 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_begin_subtest "Message with .. in Message-Id:"
add_message [id]=123..456 at example '[subject]="Message with .. in Message-Id"'
test_emacs '(notmuch-search "id:\"123..456 at example\"")
--
1.7.8.1
More information about the notmuch
mailing list