2 test_description='database upgrades'
3 . $(dirname "$0")/test-lib.sh || exit 1
5 test_require_external_prereq xapian-metadata
7 XAPIAN_PATH=$MAIL_DIR/.notmuch/xapian
8 BACKUP_PATH=$MAIL_DIR/.notmuch/backups
12 features=$(xapian-metadata get $XAPIAN_PATH features | grep -v "^$key")
13 xapian-metadata set $XAPIAN_PATH features "$features"
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
24 test_begin_subtest "upgrade is triggered by missing '$key'"
26 output=$(notmuch new | grep Welcome)
29 "Welcome to a new version of notmuch! Your database will now be upgraded."
34 test_begin_subtest "backup can be restored ['$key']"
38 notmuch tag -inbox '*'
39 dump_file=$(echo ${BACKUP_PATH}/dump*)
40 notmuch restore --input=$dump_file
42 test_expect_equal_file BEFORE AFTER
46 for key in 'from/subject/message-ID in database' \
47 'indexed MIME types' \
48 'index body and headers separately'; do
50 test_begin_subtest "upgrade not triggered by missing '$key'"
52 output=$(notmuch new | grep Welcome)
53 test_expect_equal "$output" ""
57 test_begin_subtest "upgrade with configured backup dir"
58 notmuch config set database.backup_dir ${HOME}/backups
59 delete_feature 'modification tracking'
60 notmuch new | grep Backing | notmuch_dir_sanitize | sed 's/dump-[0-9T]*/dump-XXX/' > OUTPUT
62 Backing up tags to CWD/home/backups/dump-XXX.gz...
64 test_expect_equal_file EXPECTED OUTPUT
66 test_begin_subtest "upgrade with relative configured backup dir"
67 notmuch config set database.backup_dir ${HOME}/backups
68 delete_feature 'modification tracking'
69 notmuch new | grep Backing | notmuch_dir_sanitize | sed 's/dump-[0-9T]*/dump-XXX/' > OUTPUT
71 Backing up tags to CWD/home/backups/dump-XXX.gz...
73 test_expect_equal_file EXPECTED OUTPUT