X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=test%2FT400-hooks.sh;h=3a2df2f4efabe5c7c097a2d6240ac75f80305c7c;hb=2dbc5fdf5a3c40b3e44dcde7d8caffe7dbbd217f;hp=a3dd4c6308941674c96b434525faead831f042ce;hpb=4c79a2dabe38ac72eb9eb21620f2ffca5f1885c6;p=notmuch diff --git a/test/T400-hooks.sh b/test/T400-hooks.sh index a3dd4c63..3a2df2f4 100755 --- a/test/T400-hooks.sh +++ b/test/T400-hooks.sh @@ -2,6 +2,8 @@ test_description='hooks' . $(dirname "$0")/test-lib.sh || exit 1 +test_require_external_prereq xapian-delve + create_echo_hook () { local TOKEN="${RANDOM}" mkdir -p ${HOOK_DIR} @@ -13,6 +15,19 @@ EOF echo "${TOKEN}" > ${2} } +create_write_hook () { + local TOKEN="${RANDOM}" + mkdir -p ${HOOK_DIR} + cat <"${HOOK_DIR}/${1}" +#!/bin/sh +if xapian-delve ${MAIL_DIR}/.notmuch/xapian | grep -q "writing = false"; then + echo "${TOKEN}" > ${3} +fi +EOF + chmod +x "${HOOK_DIR}/${1}" + echo "${TOKEN}" > ${2} +} + create_failing_hook () { local HOOK_DIR=${2} mkdir -p ${HOOK_DIR} @@ -28,9 +43,10 @@ add_message # create maildir structure for notmuch-insert mkdir -p "$MAIL_DIR"/{cur,new,tmp} -for config in traditional profile explicit XDG; do +for config in traditional profile explicit XDG split; do unset NOTMUCH_PROFILE notmuch config set database.hook_dir + notmuch config set database.path ${MAIL_DIR} case $config in traditional) HOOK_DIR=${MAIL_DIR}/.notmuch/hooks @@ -50,6 +66,12 @@ for config in traditional profile explicit XDG; do XDG) HOOK_DIR=${HOME}/.config/notmuch/default/hooks ;; + split) + dir="$TMP_DIRECTORY/database.$test_count" + notmuch config set database.path $dir + notmuch config set database.mail_root $MAIL_DIR + HOOK_DIR=${dir}/hooks + ;; esac test_begin_subtest "pre-new is run [${config}]" @@ -137,6 +159,18 @@ EOF chmod +x "${HOOK_DIR}/pre-new" test_expect_code 1 "notmuch new" + test_begin_subtest "post-new with write access [${config}]" + rm -rf ${HOOK_DIR} + create_write_hook "post-new" write.expected write.output $HOOK_DIR + NOTMUCH_NEW + test_expect_equal_file write.expected write.output + + test_begin_subtest "pre-new with write access [${config}]" + rm -rf ${HOOK_DIR} + create_write_hook "pre-new" write.expected write.output $HOOK_DIR + NOTMUCH_NEW + test_expect_equal_file write.expected write.output + rm -rf ${HOOK_DIR} done test_done