]> git.notmuchmail.org Git - notmuch/blobdiff - test/T400-hooks.sh
lib/database: delete stemmer on destroy
[notmuch] / test / T400-hooks.sh
index a2b67d59b5de42abdb162e71be8c02025cd23c53..0c84b7dd812ed407e17ac88f6dd23f8d8324bd25 100755 (executable)
@@ -28,6 +28,16 @@ EOF
     echo "${TOKEN}" > ${2}
 }
 
+create_change_hook () {
+    mkdir -p ${HOOK_DIR}
+    cat <<EOF >"${HOOK_DIR}/${1}"
+#!/bin/sh
+notmuch insert --no-hooks < ${2} > /dev/null
+rm -f ${2}
+EOF
+    chmod +x "${HOOK_DIR}/${1}"
+}
+
 create_failing_hook () {
     local HOOK_DIR=${2}
     mkdir -p ${HOOK_DIR}
@@ -43,9 +53,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 relative 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
@@ -62,9 +73,20 @@ for config in traditional profile explicit XDG; do
            mkdir -p $HOOK_DIR
            notmuch config set database.hook_dir $HOOK_DIR
            ;;
+       relative)
+           HOOK_DIR=${HOME}/.notmuch-hooks
+           mkdir -p $HOOK_DIR
+           notmuch config set database.hook_dir .notmuch-hooks
+           ;;
        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}]"
@@ -159,12 +181,25 @@ EOF
     test_expect_equal_file write.expected write.output
 
     test_begin_subtest "pre-new with write access [${config}]"
-    test_subtest_known_broken
     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
 
+    test_begin_subtest "add message in pre-new [${config}]"
+    rm -rf ${HOOK_DIR}
+    generate_message '[subject]="add msg in pre-new"'
+    id1=$gen_msg_id
+    create_change_hook "pre-new" $gen_msg_filename $HOOK_DIR
+    generate_message '[subject]="add msg in new"'
+    NOTMUCH_NEW
+    notmuch search id:$id1 or id:$gen_msg_id | notmuch_search_sanitize > OUTPUT
+    cat <<EOF | sed s'/^[ \t]*//' > EXPECTED
+    thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; add msg in pre-new (inbox unread)
+    thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; add msg in new (inbox unread)
+EOF
+    test_expect_equal_file EXPECTED OUTPUT
+
     rm -rf ${HOOK_DIR}
 done
 test_done