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'
10 test_begin_subtest 'at most 1 thread-id per xapian document'
11 db=${MAIL_DIR}/.notmuch/xapian
12 for doc in $(xapian-delve -1 -t '' "$db" | grep '^[1-9]'); do
13 xapian-delve -1 -r "$doc" "$db" | grep -c '^G'
15 sort -u < OUTPUT.raw > OUTPUT
20 test_expect_equal_file EXPECTED OUTPUT
22 test_begin_subtest 'search: first indexed subject preserved'
24 thread:XXX 2001-01-05 [1/1(3)] Notmuch Test Suite; message 1 (inbox unread)
26 notmuch search id:duplicate | notmuch_search_sanitize > OUTPUT
27 test_expect_equal_file EXPECTED OUTPUT
29 test_begin_subtest 'First subject preserved in notmuch-show (json)'
30 test_subtest_known_broken
31 output=$(notmuch show --body=false --format=json id:duplicate | notmuch_json_show_sanitize)
37 "'"${MAIL_DIR}"/copy0'",
38 "'"${MAIL_DIR}"/copy1'",
39 "'"${MAIL_DIR}"/copy2'"
42 "date_relative": "2001-01-05",
43 "tags": ["inbox","unread"],
45 "Subject": "message 1",
46 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
47 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
48 "Date": "GENERATED_DATE"
52 test_expect_equal_json "$output" "$expected"
54 test_begin_subtest 'Search for second subject'
60 notmuch search --output=files subject:'"message 2"' | notmuch_dir_sanitize > OUTPUT
61 test_expect_equal_file EXPECTED OUTPUT
63 test_begin_subtest 'Regexp search for second subject'
64 test_subtest_known_broken
70 notmuch search --output=files 'subject:"/message 2/"' | notmuch_dir_sanitize > OUTPUT
71 test_expect_equal_file EXPECTED OUTPUT
73 add_message '[id]="duplicate"' '[body]="sekrit" [filename]=copy3'
74 test_begin_subtest 'search for body in duplicate file'
81 notmuch search --output=files "sekrit" | notmuch_dir_sanitize > OUTPUT
82 test_expect_equal_file EXPECTED OUTPUT
85 test_begin_subtest 'reindex drops terms in duplicate file'
88 notmuch search --output=files "sekrit" | notmuch_dir_sanitize > OUTPUT
89 test_expect_equal_file EXPECTED OUTPUT
91 test_begin_subtest 'reindex choses subject from first filename'
93 thread:XXX 2001-01-05 [1/1(3)] Notmuch Test Suite; message 0 (inbox unread)
95 notmuch search id:duplicate | notmuch_search_sanitize > OUTPUT
96 test_expect_equal_file EXPECTED OUTPUT
99 test_begin_subtest 'Deleted first duplicate file does not stop notmuch show from working'
100 output=$(notmuch show --body=false --format=json id:duplicate |
101 notmuch_json_show_sanitize | sed 's/message [0-9]/A_SUBJECT/')
108 "'"${MAIL_DIR}"/copy0'",
109 "'"${MAIL_DIR}"/copy1'",
110 "'"${MAIL_DIR}"/copy2'"
113 "date_relative": "2001-01-05",
114 "tags": ["inbox","unread"],
116 "Subject": "A_SUBJECT",
117 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
118 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
119 "Date": "GENERATED_DATE"
124 test_expect_equal_json "$output" "$expected"