Test the insert --must-index option. --- test/T070-insert.sh | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/test/T070-insert.sh b/test/T070-insert.sh index c576efc..4e289c0 100755 --- a/test/T070-insert.sh +++ b/test/T070-insert.sh @@ -21,11 +21,20 @@ gen_insert_msg() { test_expect_code 2 "Insert zero-length file" \ "notmuch insert < /dev/null" -# This test is a proxy for other errors that may occur while trying to -# add a message to the notmuch database, e.g. database locked. -test_expect_code 0 "Insert non-message" \ +test_expect_code 3 "Insert non-message with --must-index on" \ + "echo bad_message | notmuch insert --must-index" + +test_begin_subtest "Non-message file should not exist" +output=$(find "${MAIL_DIR}/cur" "${MAIL_DIR}/new" "${MAIL_DIR}/tmp" -type f -print | wc -l) +test_expect_equal "$output" "0" + +test_expect_code 0 "Insert non-message with --must-index off" \ "echo bad_message | notmuch insert" +test_begin_subtest "Non-message file should exist" +output=$(find "${MAIL_DIR}/cur" "${MAIL_DIR}/new" "${MAIL_DIR}/tmp" -type f -print | wc -l) +test_expect_equal "$output" "1" + test_begin_subtest "Database empty so far" test_expect_equal "0" "`notmuch count --output=messages '*'`" @@ -77,6 +86,19 @@ notmuch insert +custom -unread < "$gen_msg_filename" output=$(notmuch search --output=messages tag:custom NOT tag:unread) test_expect_equal "$output" "id:$gen_msg_id" +# overlongtag exceeds NOTMUCH_TAG_MAX +ten=0123456789 +hundred=${ten}${ten}${ten}${ten}${ten}${ten}${ten}${ten}${ten}${ten} +overlongtag=x${hundred}${hundred} +gen_insert_msg +test_expect_code 3 "Tagging fails with --must-index on" \ + "notmuch insert --must-index +$overlongtag < $gen_msg_filename" + +test_begin_subtest "Tagging fails with --must-index off" +notmuch insert +$overlongtag < "$gen_msg_filename" +output=$(notmuch search --output=messages id:$gen_msg_id) +test_expect_equal "$output" "id:$gen_msg_id" + test_begin_subtest "Insert message with default tags stays in new/" gen_insert_msg notmuch insert < "$gen_msg_filename" -- 1.8.4