]> git.cworth.org Git - notmuch/blob - test/T700-reindex.sh
Add debian/upstream/metadata (for DEP-12)
[notmuch] / test / T700-reindex.sh
1 #!/usr/bin/env bash
2 test_description='reindexing messages'
3 . $(dirname "$0")/test-lib.sh || exit 1
4
5 add_email_corpus
6
7 notmuch tag +usertag1 '*'
8
9 notmuch search '*' | notmuch_search_sanitize > initial-threads
10 notmuch search --output=messages '*' > initial-message-ids
11 notmuch dump > initial-dump
12
13 test_begin_subtest 'reindex preserves threads'
14 notmuch reindex '*'
15 notmuch search '*' | notmuch_search_sanitize > OUTPUT
16 test_expect_equal_file initial-threads OUTPUT
17
18 test_begin_subtest 'reindex after removing duplicate file preserves threads'
19 # remove one copy
20 sed 's,3/3(4),3/3,' < initial-threads > EXPECTED
21 mv $MAIL_DIR/bar/18:2, duplicate-msg-1.eml
22 notmuch reindex '*'
23 notmuch search '*' | notmuch_search_sanitize > OUTPUT
24 test_expect_equal_file EXPECTED OUTPUT
25
26 test_begin_subtest 'reindex preserves message-ids'
27 notmuch reindex '*'
28 notmuch search --output=messages '*' > OUTPUT
29 test_expect_equal_file initial-message-ids OUTPUT
30
31 test_begin_subtest 'reindex preserves tags'
32 notmuch reindex '*'
33 notmuch dump > OUTPUT
34 test_expect_equal_file initial-dump OUTPUT
35
36 test_begin_subtest 'reindex moves a message between threads'
37 notmuch search --output=threads id:87iqd9rn3l.fsf@vertex.dottedmag > EXPECTED
38 # re-parent
39 sed -i 's/1258471718-6781-1-git-send-email-dottedmag@dottedmag.net/87iqd9rn3l.fsf@vertex.dottedmag/' $MAIL_DIR/02:2,*
40 notmuch reindex id:1258471718-6781-2-git-send-email-dottedmag@dottedmag.net
41 notmuch search --output=threads id:1258471718-6781-2-git-send-email-dottedmag@dottedmag.net > OUTPUT
42 test_expect_equal_file EXPECTED OUTPUT
43
44 test_begin_subtest 'reindex detects removal of all files'
45 notmuch search --output=messages not id:20091117232137.GA7669@griffis1.net> EXPECTED
46 # remove both copies
47 mv $MAIL_DIR/cur/51:2,* duplicate-message-2.eml
48 notmuch reindex id:20091117232137.GA7669@griffis1.net
49 notmuch search --output=messages '*' > OUTPUT
50 test_expect_equal_file EXPECTED OUTPUT
51
52 test_begin_subtest "reindex preserves properties"
53 cat <<EOF > prop-dump
54 #= 1258471718-6781-1-git-send-email-dottedmag@dottedmag.net userprop=userval
55 #= 1258471718-6781-2-git-send-email-dottedmag@dottedmag.net userprop=userval
56 #= 1258491078-29658-1-git-send-email-dottedmag@dottedmag.net userprop=userval1
57 #= 20091117190054.GU3165@dottiness.seas.harvard.edu userprop=userval
58 #= 20091117203301.GV3165@dottiness.seas.harvard.edu userprop=userval3
59 #= 87fx8can9z.fsf@vertex.dottedmag userprop=userval2
60 #= 87iqd9rn3l.fsf@vertex.dottedmag userprop=userval
61 #= 87lji4lx9v.fsf@yoom.home.cworth.org userprop=userval3
62 #= 87lji5cbwo.fsf@yoom.home.cworth.org userprop=userval
63 #= cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com userprop=userval
64 EOF
65 notmuch restore < prop-dump
66 notmuch reindex '*'
67 notmuch dump | grep '^#=' | sort > OUTPUT
68 test_expect_equal_file prop-dump OUTPUT
69
70 add_email_corpus lkml
71
72 test_begin_subtest "reindex of lkml corpus preserves threads"
73 notmuch search '*' | notmuch_search_sanitize > EXPECTED
74 notmuch reindex '*'
75 notmuch search '*' | notmuch_search_sanitize > OUTPUT
76 test_expect_equal_file EXPECTED OUTPUT
77
78 test_done