aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2011-01-15 14:05:10 -0800
committerGravatar Carl Worth <cworth@cworth.org>2011-01-15 15:37:43 -0800
commit600f3761dc48c91a5ba9a18ddeb7fd8af22e71de (patch)
treeb9240b8edfe11458cfaef24ab2a9026e8e7fc036
parentac1ba43666456a85d59031beceed2c12ef23b777 (diff)
test: Add new tests for folder-based searching.
This is a new feature which is not implemente yet, so these tests mostly fail currently. A subsequent commit will add the feature and cause these tests to start passing. These tests verify that we can search for containing folders of mail files by word or by phrase and that the search terms are updated correctly when directories are renamed.
-rwxr-xr-xtest/notmuch-test2
-rwxr-xr-xtest/search-by-folder42
2 files changed, 43 insertions, 1 deletions
diff --git a/test/notmuch-test b/test/notmuch-test
index 4889e49a..fcf43a86 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -16,7 +16,7 @@ fi
cd $(dirname "$0")
-TESTS="basic new search search-output json thread-naming raw reply dump-restore uuencode thread-order author-order from-guessing long-id encoding emacs maildir-sync"
+TESTS="basic new search search-output search-by-folder json thread-naming raw reply dump-restore uuencode thread-order author-order from-guessing long-id encoding emacs maildir-sync"
# Clean up any results from a previous run
rm -r test-results >/dev/null 2>/dev/null
diff --git a/test/search-by-folder b/test/search-by-folder
new file mode 100755
index 00000000..162158c3
--- /dev/null
+++ b/test/search-by-folder
@@ -0,0 +1,42 @@
+#!/bin/bash
+test_description='"notmuch search" by folder: (with variations)'
+. ./test-lib.sh
+
+add_message '[dir]=bad' '[subject]="To the bone"'
+add_message '[dir]=bad/news' '[subject]="Bears"'
+mkdir -p "${MAIL_DIR}/duplicate/bad/news"
+cp "$gen_msg_filename" "${MAIL_DIR}/duplicate/bad/news"
+
+add_message '[dir]=things' '[subject]="These are a few"'
+add_message '[dir]=things/favorite' '[subject]="Raindrops, whiskers, kettles"'
+add_message '[dir]=things/bad' '[subject]="Bites, stings, sad feelings"'
+
+test_begin_subtest "Single-world folder: specification (multiple results)"
+output=$(notmuch search folder:bad | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; To the bone (inbox unread)
+thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Bears (inbox unread)
+thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Bites, stings, sad feelings (inbox unread)"
+
+test_begin_subtest "Two-word path to narrow results to one"
+output=$(notmuch search folder:bad/news | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Bears (inbox unread)"
+
+test_begin_subtest "After removing duplicate instance of matching path"
+rm -r "${MAIL_DIR}/bad/news"
+increment_mtime "${MAIL_DIR}/bad"
+notmuch new
+output=$(notmuch search folder:bad/news | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Bears (inbox unread)"
+
+test_begin_subtest "After rename, old path returns nothing"
+mv "${MAIL_DIR}/duplicate/bad/news" "${MAIL_DIR}/duplicate/bad/olds"
+increment_mtime "${MAIL_DIR}/duplicate/bad"
+notmuch new
+output=$(notmuch search folder:bad/news | notmuch_search_sanitize)
+test_expect_equal "$output" ""
+
+test_begin_subtest "After rename, new path returns result"
+output=$(notmuch search folder:bad/olds | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Bears (inbox unread)"
+
+test_done