2 test_description="duplicate message ids"
3 . $(dirname "$0")/test-lib.sh || exit 1
5 add_message '[id]="duplicate"' '[subject]="message 1" [filename]=copy1'
6 add_message '[id]="duplicate"' '[subject]="message 2" [filename]=copy2'
8 add_message '[id]="duplicate"' '[subject]="message 0" [filename]=copy0'
9 test_begin_subtest 'search: first indexed subject preserved'
11 thread:XXX 2001-01-05 [1/1(3)] Notmuch Test Suite; message 1 (inbox unread)
13 notmuch search id:duplicate | notmuch_search_sanitize > OUTPUT
14 test_expect_equal_file EXPECTED OUTPUT
16 test_begin_subtest 'First subject preserved in notmuch-show (json)'
17 test_subtest_known_broken
18 output=$(notmuch show --body=false --format=json id:duplicate | notmuch_json_show_sanitize)
24 "'"${MAIL_DIR}"/copy0'",
25 "'"${MAIL_DIR}"/copy1'",
26 "'"${MAIL_DIR}"/copy2'"
29 "date_relative": "2001-01-05",
30 "tags": ["inbox","unread"],
32 "Subject": "message 1",
33 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
34 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
35 "Date": "GENERATED_DATE"
39 test_expect_equal_json "$output" "$expected"
41 test_begin_subtest 'Search for second subject'
47 notmuch search --output=files subject:'"message 2"' | notmuch_dir_sanitize > OUTPUT
48 test_expect_equal_file EXPECTED OUTPUT
50 test_begin_subtest 'Regexp search for second subject'
51 # Note that missing field processor support really means the test
52 # doesn't make sense, but it happens to pass.
53 if [ $NOTMUCH_HAVE_XAPIAN_FIELD_PROCESSOR -eq 1 ]; then
54 test_subtest_known_broken
61 notmuch search --output=files 'subject:"/message 2/"' | notmuch_dir_sanitize > OUTPUT
62 test_expect_equal_file EXPECTED OUTPUT
64 add_message '[id]="duplicate"' '[body]="sekrit" [filename]=copy3'
65 test_begin_subtest 'search for body in duplicate file'
72 notmuch search --output=files "sekrit" | notmuch_dir_sanitize > OUTPUT
73 test_expect_equal_file EXPECTED OUTPUT
76 test_begin_subtest 'reindex drops terms in duplicate file'
79 notmuch search --output=files "sekrit" | notmuch_dir_sanitize > OUTPUT
80 test_expect_equal_file EXPECTED OUTPUT
82 test_begin_subtest 'reindex choses subject from first filename'
84 thread:XXX 2001-01-05 [1/1(3)] Notmuch Test Suite; message 0 (inbox unread)
86 notmuch search id:duplicate | notmuch_search_sanitize > OUTPUT
87 test_expect_equal_file EXPECTED OUTPUT
90 test_begin_subtest 'Deleted first duplicate file does not stop notmuch show from working'
91 output=$(notmuch show --body=false --format=json id:duplicate |
92 notmuch_json_show_sanitize | sed 's/message [0-9]/A_SUBJECT/')
98 "'"${MAIL_DIR}"/copy0'",
99 "'"${MAIL_DIR}"/copy1'",
100 "'"${MAIL_DIR}"/copy2'"
103 "date_relative": "2001-01-05",
104 "tags": ["inbox","unread"],
106 "Subject": "A_SUBJECT",
107 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
108 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
109 "Date": "GENERATED_DATE"
114 test_expect_equal_json "$output" "$expected"