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 db=${MAIL_DIR}/.notmuch/xapian
14 for doc in $(xapian-delve -1 -t '' "$db" | grep '^[1-9]'); do
15 xapian-delve -1 -r "$doc" "$db" | grep -c '^G'
17 sort -u < OUTPUT.raw > OUTPUT
22 test_expect_equal_file EXPECTED OUTPUT
24 test_begin_subtest 'search: first indexed subject preserved'
26 thread:XXX 2001-01-05 [1/1(3)] Notmuch Test Suite; message 1 (inbox unread)
28 notmuch search id:duplicate | notmuch_search_sanitize > OUTPUT
29 test_expect_equal_file EXPECTED OUTPUT
31 test_begin_subtest 'First subject preserved in notmuch-show (json)'
32 test_subtest_known_broken
33 output=$(notmuch show --body=false --format=json id:duplicate | notmuch_json_show_sanitize)
39 "'"${MAIL_DIR}"/copy0'",
40 "'"${MAIL_DIR}"/copy1'",
41 "'"${MAIL_DIR}"/copy2'"
44 "date_relative": "2001-01-05",
45 "tags": ["inbox","unread"],
47 "Subject": "message 1",
48 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
49 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
50 "Date": "GENERATED_DATE"
54 test_expect_equal_json "$output" "$expected"
56 test_begin_subtest 'Search for second subject'
62 notmuch search --output=files subject:'"message 2"' | notmuch_dir_sanitize > OUTPUT
63 test_expect_equal_file EXPECTED OUTPUT
65 test_begin_subtest 'Regexp search for second subject'
66 test_subtest_known_broken
72 notmuch search --output=files 'subject:"/message 2/"' | notmuch_dir_sanitize > OUTPUT
73 test_expect_equal_file EXPECTED OUTPUT
75 add_message '[id]="duplicate"' '[body]="sekrit" [filename]=copy3'
76 test_begin_subtest 'search for body in duplicate file'
83 notmuch search --output=files "sekrit" | notmuch_dir_sanitize > OUTPUT
84 test_expect_equal_file EXPECTED OUTPUT
87 test_begin_subtest 'reindex drops terms in duplicate file'
90 notmuch search --output=files "sekrit" | notmuch_dir_sanitize > OUTPUT
91 test_expect_equal_file EXPECTED OUTPUT
93 test_begin_subtest 'reindex choses subject from first filename'
95 thread:XXX 2001-01-05 [1/1(3)] Notmuch Test Suite; message 0 (inbox unread)
97 notmuch search id:duplicate | notmuch_search_sanitize > OUTPUT
98 test_expect_equal_file EXPECTED OUTPUT
101 test_begin_subtest 'Deleted first duplicate file does not stop notmuch show from working'
102 output=$(notmuch show --body=false --format=json id:duplicate |
103 notmuch_json_show_sanitize | sed 's/message [0-9]/A_SUBJECT/')
110 "'"${MAIL_DIR}"/copy0'",
111 "'"${MAIL_DIR}"/copy1'",
112 "'"${MAIL_DIR}"/copy2'"
115 "date_relative": "2001-01-05",
116 "tags": ["inbox","unread"],
118 "Subject": "A_SUBJECT",
119 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
120 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
121 "Date": "GENERATED_DATE"
126 test_expect_equal_json "$output" "$expected"