aboutsummaryrefslogtreecommitdiff
path: root/test/T055-path-config.sh
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2020-12-31 18:20:31 -0400
committerDavid Bremner <david@tethera.net>2021-03-20 07:39:12 -0300
commite823d05ae6dc920d4fc9abf774c3d2575d891d7b (patch)
treea66d028308be1a14a3b6f5fcae9feaa12cc3aede /test/T055-path-config.sh
parent986056bdbcfea642a2d08f7ee257f7aaaed433b9 (diff)
lib: support splitting mail from database location.
Introduce a new configuration value for the mail root, and use it to locate mail messages in preference to the database.path (which previously implied the mail messages were also in this location. Initially only a subset of the CLI is tested in a split configuration. Further changes will be needed for the remainder of the CLI to work in split configurations.
Diffstat (limited to 'test/T055-path-config.sh')
-rwxr-xr-xtest/T055-path-config.sh90
1 files changed, 90 insertions, 0 deletions
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
new file mode 100755
index 00000000..c6920ca9
--- /dev/null
+++ b/test/T055-path-config.sh
@@ -0,0 +1,90 @@
+#!/usr/bin/env bash
+test_description='Configuration of mail-root and database path'
+. $(dirname "$0")/test-lib.sh || exit 1
+
+backup_config () {
+ local test_name=$(basename $0 .sh)
+ cp ${NOTMUCH_CONFIG} notmuch-config-backup.${test_name}
+}
+
+restore_config () {
+ local test_name=$(basename $0 .sh)
+ export NOTMUCH_CONFIG="${TMP_DIRECTORY}/notmuch-config"
+ unset CONFIG_PATH
+ unset DATABASE_PATH
+ unset NOTMUCH_PROFILE
+ cp notmuch-config-backup.${test_name} ${NOTMUCH_CONFIG}
+}
+
+split_config () {
+ local dir
+ backup_config
+ dir="$TMP_DIRECTORY/database.$test_count"
+ rm -rf $dir
+ mkdir $dir
+ notmuch config set database.path $dir
+ notmuch config set database.mail_root $MAIL_DIR
+ DATABASE_PATH=$dir
+}
+
+
+
+for config in traditional split; do
+ # start each set of tests with a known set of messages
+ add_email_corpus
+
+ case $config in
+ traditional)
+ backup_config
+ ;;
+ split)
+ split_config
+ mv mail/.notmuch/xapian $DATABASE_PATH
+ ;;
+ esac
+
+ test_begin_subtest "count ($config)"
+ output=$(notmuch count '*')
+ test_expect_equal "$output" '52'
+
+ test_begin_subtest "count+tag ($config)"
+ tag="tag${RANDOM}"
+ notmuch tag +$tag '*'
+ output=$(notmuch count tag:$tag)
+ notmuch tag -$tag '*'
+ test_expect_equal "$output" '52'
+
+ test_begin_subtest "address ($config)"
+ notmuch address --deduplicate=no --sort=newest-first --output=sender --output=recipients path:foo >OUTPUT
+ cat <<EOF >EXPECTED
+Carl Worth <cworth@cworth.org>
+notmuch@notmuchmail.org
+EOF
+ test_expect_equal_file EXPECTED OUTPUT
+
+ test_begin_subtest "dump ($config)"
+ notmuch dump is:attachment and is:signed | sort > OUTPUT
+ cat <<EOF > EXPECTED
+#notmuch-dump batch-tag:3 config,properties,tags
++attachment +inbox +signed +unread -- id:20091118005829.GB25380@dottiness.seas.harvard.edu
++attachment +inbox +signed +unread -- id:20091118010116.GC25380@dottiness.seas.harvard.edu
+EOF
+ test_expect_equal_file EXPECTED OUTPUT
+
+ test_begin_subtest "dump + tag + restore ($config)"
+ notmuch dump '*' > EXPECTED
+ notmuch tag -inbox '*'
+ notmuch restore < EXPECTED
+ notmuch dump > OUTPUT
+ test_expect_equal_file EXPECTED OUTPUT
+
+ test_begin_subtest "reindex ($config)"
+ notmuch search --output=messages '*' > EXPECTED
+ notmuch reindex '*'
+ notmuch search --output=messages '*' > OUTPUT
+ test_expect_equal_file EXPECTED OUTPUT
+
+ restore_config
+done
+
+test_done