]> git.notmuchmail.org Git - notmuch/blob - test/T670-duplicate-mid.sh
show: workaround for the missing file problem
[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 test_begin_subtest 'First subject preserved'
9 cat <<EOF > EXPECTED
10 thread:XXX   2001-01-05 [1/1(2)] Notmuch Test Suite; message 1 (inbox unread)
11 EOF
12 notmuch search id:duplicate | notmuch_search_sanitize > OUTPUT
13 test_expect_equal_file EXPECTED OUTPUT
14
15 test_begin_subtest 'Search for second subject'
16 cat <<EOF >EXPECTED
17 MAIL_DIR/copy1
18 MAIL_DIR/copy2
19 EOF
20 notmuch search --output=files subject:'"message 2"' | notmuch_dir_sanitize > OUTPUT
21 test_expect_equal_file EXPECTED OUTPUT
22
23 add_message '[id]="duplicate"' '[body]="sekrit" [filename]=copy3'
24 test_begin_subtest 'search for body in duplicate file'
25 cat <<EOF >EXPECTED
26 MAIL_DIR/copy1
27 MAIL_DIR/copy2
28 MAIL_DIR/copy3
29 EOF
30 notmuch search --output=files "sekrit" | notmuch_dir_sanitize > OUTPUT
31 test_expect_equal_file EXPECTED OUTPUT
32
33 rm ${MAIL_DIR}/copy3
34 test_begin_subtest 'reindex drops terms in duplicate file'
35 cp /dev/null EXPECTED
36 notmuch reindex '*'
37 notmuch search --output=files "sekrit" | notmuch_dir_sanitize > OUTPUT
38 test_expect_equal_file EXPECTED OUTPUT
39
40 rm ${MAIL_DIR}/copy1
41 test_begin_subtest 'Deleted first duplicate file does not stop notmuch show from working'
42 output=$(notmuch show --body=false --format=json id:duplicate)
43 expected='[[[{
44     "id": "'duplicate'",
45     "match": true,
46     "excluded": false,
47     "filename": [
48         "'"${MAIL_DIR}"/copy1'",
49         "'"${MAIL_DIR}"/copy2'"
50     ],
51     "timestamp": 978709435,
52     "date_relative": "2001-01-05",
53     "tags": ["inbox","unread"],
54     "headers": {
55         "Subject": "message 2",
56         "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
57         "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
58         "Date": "Fri, 05 Jan 2001 15:43:55 +0000"
59     }
60  },
61 []]]]'
62
63 test_expect_equal_json "$output" "$expected"
64
65 test_done