2 test_description="duplicate message ids"
3 . $(dirname "$0")/test-lib.sh || exit 1
5 test_require_external_prereq xapian-delve
7 add_message '[id]="duplicate"' '[subject]="message 1" [filename]=copy1'
8 add_message '[id]="duplicate"' '[subject]="message 2" [filename]=copy2'
10 add_message '[id]="duplicate"' '[subject]="message 0" [filename]=copy0'
12 test_begin_subtest 'at most 1 thread-id per xapian document'
13 test_subtest_known_broken
14 db=${MAIL_DIR}/.notmuch/xapian
15 for doc in $(xapian-delve -1 -t '' "$db" | grep '^[1-9]'); do
16 xapian-delve -1 -r "$doc" "$db" | grep -c '^G'
18 sort -u < OUTPUT.raw > OUTPUT
23 test_expect_equal_file EXPECTED OUTPUT
25 test_begin_subtest 'search: first indexed subject preserved'
27 thread:XXX 2001-01-05 [1/1(3)] Notmuch Test Suite; message 1 (inbox unread)
29 notmuch search id:duplicate | notmuch_search_sanitize > OUTPUT
30 test_expect_equal_file EXPECTED OUTPUT
32 test_begin_subtest 'First subject preserved in notmuch-show (json)'
33 test_subtest_known_broken
34 output=$(notmuch show --body=false --format=json id:duplicate | notmuch_json_show_sanitize)
40 "'"${MAIL_DIR}"/copy0'",
41 "'"${MAIL_DIR}"/copy1'",
42 "'"${MAIL_DIR}"/copy2'"
45 "date_relative": "2001-01-05",
46 "tags": ["inbox","unread"],
48 "Subject": "message 1",
49 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
50 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
51 "Date": "GENERATED_DATE"
55 test_expect_equal_json "$output" "$expected"
57 test_begin_subtest 'Search for second subject'
63 notmuch search --output=files subject:'"message 2"' | notmuch_dir_sanitize > OUTPUT
64 test_expect_equal_file EXPECTED OUTPUT
66 test_begin_subtest 'Regexp search for second subject'
67 test_subtest_known_broken
73 notmuch search --output=files 'subject:"/message 2/"' | notmuch_dir_sanitize > OUTPUT
74 test_expect_equal_file EXPECTED OUTPUT
76 add_message '[id]="duplicate"' '[body]="sekrit" [filename]=copy3'
77 test_begin_subtest 'search for body in duplicate file'
84 notmuch search --output=files "sekrit" | notmuch_dir_sanitize > OUTPUT
85 test_expect_equal_file EXPECTED OUTPUT
88 test_begin_subtest 'reindex drops terms in duplicate file'
91 notmuch search --output=files "sekrit" | notmuch_dir_sanitize > OUTPUT
92 test_expect_equal_file EXPECTED OUTPUT
94 test_begin_subtest 'reindex choses subject from first filename'
96 thread:XXX 2001-01-05 [1/1(3)] Notmuch Test Suite; message 0 (inbox unread)
98 notmuch search id:duplicate | notmuch_search_sanitize > OUTPUT
99 test_expect_equal_file EXPECTED OUTPUT
102 test_begin_subtest 'Deleted first duplicate file does not stop notmuch show from working'
103 output=$(notmuch show --body=false --format=json id:duplicate |
104 notmuch_json_show_sanitize | sed 's/message [0-9]/A_SUBJECT/')
111 "'"${MAIL_DIR}"/copy0'",
112 "'"${MAIL_DIR}"/copy1'",
113 "'"${MAIL_DIR}"/copy2'"
116 "date_relative": "2001-01-05",
117 "tags": ["inbox","unread"],
119 "Subject": "A_SUBJECT",
120 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
121 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
122 "Date": "GENERATED_DATE"
127 test_expect_equal_json "$output" "$expected"