]> git.notmuchmail.org Git - notmuch/blob - test/T670-duplicate-mid.sh
test: known broken test for subject after reindexing
[notmuch] / test / T670-duplicate-mid.sh
1 #!/usr/bin/env bash
2 test_description="duplicate message ids"
3 . ./test-lib.sh || exit 1
4
5 add_message '[id]="duplicate"' '[subject]="message 1" [filename]=copy1'
6 add_message '[id]="duplicate"' '[subject]="message 2" [filename]=copy2'
7
8 add_message '[id]="duplicate"' '[subject]="message 0" [filename]=copy0'
9 test_begin_subtest 'search: first indexed subject preserved'
10 cat <<EOF > EXPECTED
11 thread:XXX   2001-01-05 [1/1(3)] Notmuch Test Suite; message 1 (inbox unread)
12 EOF
13 notmuch search id:duplicate | notmuch_search_sanitize > OUTPUT
14 test_expect_equal_file EXPECTED OUTPUT
15
16 test_begin_subtest 'Search for second subject'
17 cat <<EOF >EXPECTED
18 MAIL_DIR/copy0
19 MAIL_DIR/copy1
20 MAIL_DIR/copy2
21 EOF
22 notmuch search --output=files subject:'"message 2"' | notmuch_dir_sanitize > OUTPUT
23 test_expect_equal_file EXPECTED OUTPUT
24
25 add_message '[id]="duplicate"' '[body]="sekrit" [filename]=copy3'
26 test_begin_subtest 'search for body in duplicate file'
27 cat <<EOF >EXPECTED
28 MAIL_DIR/copy0
29 MAIL_DIR/copy1
30 MAIL_DIR/copy2
31 MAIL_DIR/copy3
32 EOF
33 notmuch search --output=files "sekrit" | notmuch_dir_sanitize > OUTPUT
34 test_expect_equal_file EXPECTED OUTPUT
35
36 rm ${MAIL_DIR}/copy3
37 test_begin_subtest 'reindex drops terms in duplicate file'
38 cp /dev/null EXPECTED
39 notmuch reindex '*'
40 notmuch search --output=files "sekrit" | notmuch_dir_sanitize > OUTPUT
41 test_expect_equal_file EXPECTED OUTPUT
42
43 test_begin_subtest 'reindex choses subject from first filename'
44 test_subtest_known_broken
45 cat <<EOF > EXPECTED
46 thread:XXX   2001-01-05 [1/1(3)] Notmuch Test Suite; message 0 (inbox unread)
47 EOF
48 notmuch search id:duplicate | notmuch_search_sanitize > OUTPUT
49 test_expect_equal_file EXPECTED OUTPUT
50
51 rm ${MAIL_DIR}/copy0
52 test_begin_subtest 'Deleted first duplicate file does not stop notmuch show from working'
53 output=$(notmuch show --body=false --format=json id:duplicate |
54              notmuch_json_show_sanitize | sed 's/message [0-9]/A_SUBJECT/')
55 expected='[[[{
56     "id": "XXXXX",
57     "match": true,
58     "excluded": false,
59     "filename": [
60         "'"${MAIL_DIR}"/copy0'",
61         "'"${MAIL_DIR}"/copy1'",
62         "'"${MAIL_DIR}"/copy2'"
63     ],
64     "timestamp": 42,
65     "date_relative": "2001-01-05",
66     "tags": ["inbox","unread"],
67     "headers": {
68         "Subject": "A_SUBJECT",
69         "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
70         "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
71         "Date": "GENERATED_DATE"
72     }
73  },
74 []]]]'
75
76 test_expect_equal_json "$output" "$expected"
77
78 test_done