From: Mark Walters Date: Sun, 25 Nov 2012 16:23:17 +0000 (+0000) Subject: Re: [PATCH v2 18/20] test: add tests for insert X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=b803eb728c41723770431c4d7a7fbe64e1638ae3;p=notmuch-archives.git Re: [PATCH v2 18/20] test: add tests for insert --- diff --git a/50/3f3bd1ae2710c0803ba9b780a58b189d001c78 b/50/3f3bd1ae2710c0803ba9b780a58b189d001c78 new file mode 100644 index 000000000..56e07adb7 --- /dev/null +++ b/50/3f3bd1ae2710c0803ba9b780a58b189d001c78 @@ -0,0 +1,214 @@ +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 68E41431FAF + for ; Sun, 25 Nov 2012 08:23:17 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 ekTaWAYFtEAn for ; + Sun, 25 Nov 2012 08:23:16 -0800 (PST) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 743D4431FAE + for ; Sun, 25 Nov 2012 08:23:16 -0800 (PST) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1TcezC-0007X7-Ty; Sun, 25 Nov 2012 16:23:15 +0000 +Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) + (envelope-from ) + id 1TcezC-0001cU-G7; Sun, 25 Nov 2012 16:23:14 +0000 +From: Mark Walters +To: Peter Wang , notmuch@notmuchmail.org +Subject: Re: [PATCH v2 18/20] test: add tests for insert +In-Reply-To: <1353806206-29133-19-git-send-email-novalazy@gmail.com> +References: <1353806206-29133-1-git-send-email-novalazy@gmail.com> + <1353806206-29133-19-git-send-email-novalazy@gmail.com> +User-Agent: Notmuch/0.14+81~g9730584 (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Sun, 25 Nov 2012 16:23:17 +0000 +Message-ID: <87zk25ird6.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 93.97.24.31 +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: b6bd8c379cb97ab08c491760b11ceac9 (of first 20000 bytes) +X-SpamAssassin-Score: -1.8 +X-SpamAssassin-SpamBar: - +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -1.8 points. + Summary of the scoring: + * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, + * medium trust + * [138.37.6.40 listed in list.dnswl.org] + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * 0.5 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +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: Sun, 25 Nov 2012 16:23:17 -0000 + +On Sun, 25 Nov 2012, Peter Wang wrote: +> Add tests for new 'insert' command. +> --- +> test/insert | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ +> test/notmuch-test | 1 + +> 2 files changed, 94 insertions(+) +> create mode 100755 test/insert +> +> diff --git a/test/insert b/test/insert +> new file mode 100755 +> index 0000000..d821a41 +> --- /dev/null +> +++ b/test/insert +> @@ -0,0 +1,93 @@ +> +#!/usr/bin/env bash +> +test_description='"notmuch insert"' +> +. ./test-lib.sh +> + +> +# Create directories and database before inserting. +> +mkdir -p "$MAIL_DIR"/{cur,new,tmp} +> +mkdir -p "$MAIL_DIR"/Drafts/{cur,new,tmp} +> +notmuch new > /dev/null +> + +> +# We use generate_message to create the temporary message file. +> +# It happens to be in the mail directory already but that is okay. + +Perhaps add "since we do not call notmuch new". + +> + +> +test_begin_subtest "Insert message, default" +> +generate_message \ +> + "[subject]=\"insert-subject\"" \ +> + "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \ +> + "[body]=\"insert-message\"" +> +notmuch insert < "$gen_msg_filename" +> +test_expect_equal "`notmuch count subject:insert-subject tag:unread`" "1" + +I would much prefer to test that we have the proper full message here +with something like notmuch show or something. I would like +something that tests that the full message has actually been written to +disk. + +> +test_begin_subtest "Insert message, add tag" +> +generate_message \ +> + "[subject]=\"insert-subject-addtag\"" \ +> + "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \ +> + "[body]=\"insert-message-addtag\"" +> +notmuch insert +custom < "$gen_msg_filename" +> +test_expect_equal "`notmuch count tag:custom`" "1" +> + +> +test_begin_subtest "Insert message, add/remove tag" +> +generate_message \ +> + "[subject]=\"insert-subject-addrmtag\"" \ +> + "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \ +> + "[body]=\"insert-message-addrmtag\"" +> +notmuch insert +custom -unread < "$gen_msg_filename" +> +test_expect_equal "`notmuch count tag:custom NOT tag:unread`" "1" +> + +> +test_begin_subtest "Insert message, folder" +> +generate_message \ +> + "[subject]=\"insert-subject-draft\"" \ +> + "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \ +> + "[body]=\"insert-message-draft\"" +> +notmuch insert --folder=Drafts < "$gen_msg_filename" +> +test_expect_equal "`notmuch count folder:Drafts`" "1" +> + +> +test_begin_subtest "Insert message, folder and tags" +> +generate_message \ +> + "[subject]=\"insert-subject-draft\"" \ +> + "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \ +> + "[body]=\"insert-message-draft\"" +> +notmuch insert --folder=Drafts +draft -unread < "$gen_msg_filename" +> +test_expect_equal "`notmuch count folder:Drafts tag:draft NOT tag:unread`" "1" +> + +> +test_begin_subtest "Insert message, non-existent folder" +> +generate_message \ +> + "[subject]=\"insert-subject-nonexistfolder\"" \ +> + "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \ +> + "[body]=\"insert-message-nonexistfolder\"" +> +notmuch insert --folder=nonesuch < "$gen_msg_filename" +> +test_expect_equal "$?" "1" + +Here and for other error cases you could check that the correct error +message is being returned. + +Best wishes + +Mark +> + +> +test_begin_subtest "Insert message, create folder" +> +generate_message \ +> + "[subject]=\"insert-subject-createfolder\"" \ +> + "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \ +> + "[body]=\"insert-message-createfolder\"" +> +notmuch insert --folder=F --create-folder +folder < "$gen_msg_filename" +> +test_expect_equal "`notmuch count folder:F tag:folder`" "1" +> + +> +test_begin_subtest "Insert message, create subfolder" +> +generate_message \ +> + "[subject]=\"insert-subject-createfolder\"" \ +> + "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \ +> + "[body]=\"insert-message-createfolder\"" +> +notmuch insert --folder=F/G/H/I/J --create-folder +folder < "$gen_msg_filename" +> +test_expect_equal "`notmuch count folder:F/G/H/I/J tag:folder`" "1" +> + +> +test_begin_subtest "Insert message, create existing subfolder" +> +generate_message \ +> + "[subject]=\"insert-subject-createfolder\"" \ +> + "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \ +> + "[body]=\"insert-message-createfolder\"" +> +notmuch insert --folder=F/G/H/I/J --create-folder +folder < "$gen_msg_filename" +> +test_expect_equal "`notmuch count folder:F/G/H/I/J tag:folder`" "2" +> + +> +test_begin_subtest "Insert message, create invalid subfolder" +> +generate_message \ +> + "[subject]=\"insert-subject-createinvalidfolder\"" \ +> + "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \ +> + "[body]=\"insert-message-createinvalidfolder\"" +> +notmuch insert --folder=../G --create-folder < "$gen_msg_filename" +> +test_expect_equal "$?" "1" +> + +> +test_done +> diff --git a/test/notmuch-test b/test/notmuch-test +> index 9a1b375..09be44c 100755 +> --- a/test/notmuch-test +> +++ b/test/notmuch-test +> @@ -22,6 +22,7 @@ TESTS=" +> config +> new +> count +> + insert +> search +> search-output +> search-by-folder +> -- +> 1.7.12.1 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch