]> git.cworth.org Git - notmuch-old/blob - test/T700-reindex.sh
test: emacs: check for configured emacs
[notmuch-old] / 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 preserves tags with special prefixes'
37 notmuch tag +attachment2 +encrypted2 +signed2 '*'
38 notmuch dump > EXPECTED
39 notmuch reindex '*'
40 notmuch dump > OUTPUT
41 notmuch tag -attachment2 -encrypted2 -signed2 '*'
42 test_expect_equal_file EXPECTED OUTPUT
43
44 test_begin_subtest 'reindex moves a message between threads'
45 notmuch search --output=threads id:87iqd9rn3l.fsf@vertex.dottedmag > EXPECTED
46 # re-parent
47 sed -i 's/1258471718-6781-1-git-send-email-dottedmag@dottedmag.net/87iqd9rn3l.fsf@vertex.dottedmag/' $MAIL_DIR/02:2,*
48 notmuch reindex id:1258471718-6781-2-git-send-email-dottedmag@dottedmag.net
49 notmuch search --output=threads id:1258471718-6781-2-git-send-email-dottedmag@dottedmag.net > OUTPUT
50 test_expect_equal_file EXPECTED OUTPUT
51
52 test_begin_subtest 'reindex detects removal of all files'
53 notmuch search --output=messages not id:20091117232137.GA7669@griffis1.net> EXPECTED
54 # remove both copies
55 mv $MAIL_DIR/cur/51:2,* duplicate-message-2.eml
56 notmuch reindex id:20091117232137.GA7669@griffis1.net
57 notmuch search --output=messages '*' > OUTPUT
58 test_expect_equal_file EXPECTED OUTPUT
59
60 test_begin_subtest "reindex preserves properties"
61 cat <<EOF > prop-dump
62 #= 1258471718-6781-1-git-send-email-dottedmag@dottedmag.net userprop=userval
63 #= 1258471718-6781-2-git-send-email-dottedmag@dottedmag.net userprop=userval
64 #= 1258491078-29658-1-git-send-email-dottedmag@dottedmag.net userprop=userval1
65 #= 20091117190054.GU3165@dottiness.seas.harvard.edu userprop=userval
66 #= 20091117203301.GV3165@dottiness.seas.harvard.edu userprop=userval3
67 #= 87fx8can9z.fsf@vertex.dottedmag userprop=userval2
68 #= 87iqd9rn3l.fsf@vertex.dottedmag userprop=userval
69 #= 87lji4lx9v.fsf@yoom.home.cworth.org userprop=userval3
70 #= 87lji5cbwo.fsf@yoom.home.cworth.org userprop=userval
71 #= cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com userprop=userval
72 EOF
73 notmuch restore < prop-dump
74 notmuch reindex '*'
75 notmuch dump | grep '^#=' | sort > OUTPUT
76 test_expect_equal_file prop-dump OUTPUT
77
78 add_email_corpus lkml
79
80 test_begin_subtest "reindex of lkml corpus preserves threads"
81 notmuch search '*' | notmuch_search_sanitize > EXPECTED
82 notmuch reindex '*'
83 notmuch search '*' | notmuch_search_sanitize > OUTPUT
84 test_expect_equal_file EXPECTED OUTPUT
85
86 test_done