test:Folder tags shouldn't match after removal of file in given folder
authorMark Anderson <ma.skies@gmail.com>
Mon, 27 Jun 2011 17:12:24 +0000 (11:12 -0600)
committerDavid Bremner <bremner@debian.org>
Thu, 30 Jun 2011 00:58:19 +0000 (21:58 -0300)
Test for bug.  Current stemming support for notmuch adds extra terms
to the DB which aren't removed when the file renames are detected.

When folder tags are added to a message, Xapian terms for both XFOLDER
and ZXFOLDER are generated.  When one of the filenames are
renamed/removed, only the XFOLDER tags are removed, leaving it possible
for a match on a folder: tag that was previously but is no longer a
match in the maildir.
(cherry picked from commit 86e0baeb6df5509393832488c0de3520a1a5bdcb)

test/search-folder-coherence [new file with mode: 0755]

index fe85c6a4032f9fbd2e88ad5a2bf9afce067e8679..79e6267b803252ccf92b1df2f5e7d56bdbbd7f41 100755 (executable)
@@ -41,6 +41,7 @@ TESTS="
+  search-folder-coherence
diff --git a/test/search-folder-coherence b/test/search-folder-coherence
new file mode 100755 (executable)
index 0000000..cf3ba40
--- /dev/null
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+test_description='folder tags removed and added through file renames remain consistent'
+. ./test-lib.sh
+test_begin_subtest "No new messages"
+test_expect_equal "$output" "No new mail."
+test_begin_subtest "Single new message"
+test_expect_equal "$output" "Added 1 new message to the database."
+test_begin_subtest "Add second folder for same message"
+dir=$(dirname $file_x)
+mkdir $dir/spam
+cp $file_x $dir/spam
+test_expect_equal "$output" "No new mail."
+test_begin_subtest "Multiple files for same message"
+notmuch search --output=files id:$id_x | sed -e "s,$MAIL_DIR,MAIL_DIR," >OUTPUT
+test_expect_equal_file OUTPUT EXPECTED
+test_begin_subtest "Test matches folder:spam"
+output=$(notmuch search folder:spam)
+test_expect_equal "$output" "thread:0000000000000001   2001-01-05 [1/1] Notmuch Test Suite; Test message #1 (inbox unread)"
+sleep 1;
+test_begin_subtest "Remove folder:spam copy of email"
+rm $dir/spam/$(basename $file_x)
+test_expect_equal "$output" "No new mail. Detected 1 file rename."
+test_begin_subtest "No mails match the folder:spam search"
+output=$(notmuch search folder:spam)
+test_expect_equal "$output" ""