#!/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+prefix; do # start each set of tests with a known set of messages add_email_corpus case $config in traditional) backup_config ;; split+prefix) split_config mv mail/.notmuch $DATABASE_PATH ;; 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' restore_config done test_done