]> git.notmuchmail.org Git - notmuch/blob - test/T530-upgrade.sh
emacs: Add new option notmuch-search-hide-excluded
[notmuch] / test / T530-upgrade.sh
1 #!/usr/bin/env bash
2 test_description='database upgrades'
3 . $(dirname "$0")/test-lib.sh || exit 1
4
5 test_require_external_prereq xapian-metadata
6
7 XAPIAN_PATH=$MAIL_DIR/.notmuch/xapian
8 BACKUP_PATH=$MAIL_DIR/.notmuch/backups
9
10 delete_feature () {
11     local key=$1
12     features=$(xapian-metadata get $XAPIAN_PATH features | grep -v "^$key")
13     xapian-metadata set $XAPIAN_PATH features "$features"
14 }
15
16 add_email_corpus
17
18 for key in 'multiple paths per message' \
19                'relative directory paths' \
20                'exact folder:/path: search' \
21                'mail documents for missing messages' \
22                'modification tracking'; do
23     backup_database
24     test_begin_subtest "upgrade is triggered by missing '$key'"
25     delete_feature "$key"
26     output=$(notmuch new | grep Welcome)
27     test_expect_equal \
28         "$output" \
29         "Welcome to a new version of notmuch! Your database will now be upgraded."
30
31     restore_database
32
33     backup_database
34     test_begin_subtest "backup can be restored ['$key']"
35     notmuch dump > BEFORE
36     delete_feature "$key"
37     notmuch new
38     notmuch tag -inbox '*'
39     dump_file=$(echo ${BACKUP_PATH}/dump*)
40     notmuch restore --input=$dump_file
41     notmuch dump > AFTER
42     test_expect_equal_file BEFORE AFTER
43     restore_database
44 done
45
46 for key in 'from/subject/message-ID in database' \
47                'indexed MIME types' \
48                'index body and headers separately'; do
49     backup_database
50     test_begin_subtest "upgrade not triggered by missing '$key'"
51     delete_feature "$key"
52     output=$(notmuch new | grep Welcome)
53     test_expect_equal "$output" ""
54     restore_database
55 done
56
57 test_done