]> git.notmuchmail.org Git - notmuch/commitdiff
test: add (back) upgrade tests
authorDavid Bremner <david@tethera.net>
Sun, 17 Jan 2021 12:35:38 +0000 (08:35 -0400)
committerDavid Bremner <david@tethera.net>
Sun, 17 Jan 2021 17:24:04 +0000 (13:24 -0400)
In ee897cab8b721 the upgrade tests from pre v3 databases were
removed. The reasons for that are still valid, but we should still
test the code paths that do the upgrade, and it is relatively
straightforward to do that for v3 to v3 upgrades.

test/README
test/T530-upgrade.sh [new file with mode: 0755]
test/test-lib.sh

index 11eaf18fa3fbd27c49251cf9832d87286077312b..10f127cbbef171be491b3bc8f5b742b8e8c67111 100644 (file)
@@ -25,6 +25,7 @@ that you know if you break anything.
   - gdb(1)
   - gpg(1)
   - python(1)
+  - xapian-metadata(1)
 
 If your system lacks these tools or have older, non-upgradable versions
 of these, please (possibly compile and) install these to some other
diff --git a/test/T530-upgrade.sh b/test/T530-upgrade.sh
new file mode 100755 (executable)
index 0000000..c599dac
--- /dev/null
@@ -0,0 +1,57 @@
+#!/usr/bin/env bash
+test_description='database upgrades'
+. $(dirname "$0")/test-lib.sh || exit 1
+
+test_require_external_prereq xapian-metadata
+
+XAPIAN_PATH=$MAIL_DIR/.notmuch/xapian
+BACKUP_PATH=$MAIL_DIR/.notmuch
+
+delete_feature () {
+    local key=$1
+    features=$(xapian-metadata get $XAPIAN_PATH features | grep -v "^$key")
+    xapian-metadata set $XAPIAN_PATH features "$features"
+}
+
+add_email_corpus
+
+for key in 'multiple paths per message' \
+              'relative directory paths' \
+              'exact folder:/path: search' \
+              'mail documents for missing messages' \
+              'modification tracking'; do
+    backup_database
+    test_begin_subtest "upgrade is triggered by missing '$key'"
+    delete_feature "$key"
+    output=$(notmuch new | grep Welcome)
+    test_expect_equal \
+       "$output" \
+       "Welcome to a new version of notmuch! Your database will now be upgraded."
+
+    restore_database
+
+    backup_database
+    test_begin_subtest "backup can be restored ['$key']"
+    notmuch dump > BEFORE
+    delete_feature "$key"
+    notmuch new
+    notmuch tag -inbox '*'
+    dump_file=$(echo ${BACKUP_PATH}/dump*)
+    notmuch restore --input=$dump_file
+    notmuch dump > AFTER
+    test_expect_equal_file BEFORE AFTER
+    restore_database
+done
+
+for key in 'from/subject/message-ID in database' \
+              'indexed MIME types' \
+              'index body and headers separately'; do
+    backup_database
+    test_begin_subtest "upgrade not triggered by missing '$key'"
+    delete_feature "$key"
+    output=$(notmuch new | grep Welcome)
+    test_expect_equal "$output" ""
+    restore_database
+done
+
+test_done
index c23a0d209186d7d04bb987614540a366181ac124..29baa0c17d966f0012438aa7d60738778f819a7b 100644 (file)
@@ -1270,3 +1270,4 @@ test_declare_external_prereq gpg
 test_declare_external_prereq openssl
 test_declare_external_prereq gpgsm
 test_declare_external_prereq ${NOTMUCH_PYTHON}
+test_declare_external_prereq xapian-metadata