From: Peter Wang Date: Wed, 16 Apr 2014 12:59:24 +0000 (+1000) Subject: [PATCH v2 09/10] test: test insert --must-index X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=50b5fe5896a01f26da5554346e9426d35cc82f38;p=notmuch-archives.git [PATCH v2 09/10] test: test insert --must-index --- diff --git a/50/b26b48751479f5f5ced590da5d6f9af0a7af83 b/50/b26b48751479f5f5ced590da5d6f9af0a7af83 new file mode 100644 index 000000000..0119f0841 --- /dev/null +++ b/50/b26b48751479f5f5ced590da5d6f9af0a7af83 @@ -0,0 +1,118 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 1D017431FCB + for ; Wed, 16 Apr 2014 06:01:14 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.799 +X-Spam-Level: +X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id SjFvwWG2n6Tt for ; + Wed, 16 Apr 2014 06:01:08 -0700 (PDT) +Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com + [209.85.220.50]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 65E1F429E31 + for ; Wed, 16 Apr 2014 06:00:23 -0700 (PDT) +Received: by mail-pa0-f50.google.com with SMTP id kq14so10888609pab.37 + for ; Wed, 16 Apr 2014 06:00:22 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:in-reply-to:references; + bh=FGaSSp021HjW1miPH50nvBPcHxxNW3ZM9Sd0efFSieI=; + b=fCfThf+DrJbE8Ybasu1Q0BNuoIQ92kX9D94K6qr4o0z/BOAlRknkTX9Y6ZJR0WYPvN + WBusXaxywLvOEaAg+oOntPHNNsEcFPDQDIUdNkkqIhHR0zlOzmJeStw7+2+Usnrf6HEx + t7tAzZLkmZLvwkQGVHXFmHianzswchRoi87bZ0FQCmegeWGFjkHHWAJ/LG94ZMSPwfTp + eJIvthC2UcWVeST7n8tSAQD8qxduRCQJ4V0KKKo1TCkKWYfPwUWBIAvcUhJB6TtY6anS + B7bTOcCsnyKlZDIku8RLJvg/KqTFawrH70KamTEn7VyGsRkBrtoHujmI3XU6kP+wFs94 + D4eg== +X-Received: by 10.66.160.34 with SMTP id xh2mr8266146pab.109.1397653222700; + Wed, 16 Apr 2014 06:00:22 -0700 (PDT) +Received: from localhost (215.42.233.220.static.exetel.com.au. + [220.233.42.215]) by mx.google.com with ESMTPSA id + qx11sm110909430pab.35.2014.04.16.06.00.20 for + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Wed, 16 Apr 2014 06:00:22 -0700 (PDT) +From: Peter Wang +To: notmuch@notmuchmail.org +Subject: [PATCH v2 09/10] test: test insert --must-index +Date: Wed, 16 Apr 2014 22:59:24 +1000 +Message-Id: <1397653165-15620-10-git-send-email-novalazy@gmail.com> +X-Mailer: git-send-email 1.8.4 +In-Reply-To: <1397653165-15620-1-git-send-email-novalazy@gmail.com> +References: <1397653165-15620-1-git-send-email-novalazy@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Wed, 16 Apr 2014 13:01:14 -0000 + +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 +