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 08110431FBD for ; Sat, 13 Jul 2013 17:46:15 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_NONE=-0.0001] 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 0zaa0ruuFfTJ for ; Sat, 13 Jul 2013 17:46:07 -0700 (PDT) Received: from smtp-out-04.shaw.ca (smtp-out-04.shaw.ca [64.59.134.12]) by olra.theworths.org (Postfix) with ESMTP id 72F3A431FBC for ; Sat, 13 Jul 2013 17:46:07 -0700 (PDT) X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=YO+FcVZrxpdWV6Mo6AkY2Rtp7tuV51ZJEd1ZQZEmJbs= c=1 sm=1 a=6-n1HIq2qTAA:10 a=BLceEmwcHowA:10 a=gumk1giGF0obp6xRQyl7Yg==:17 a=7cLX10yMaAZXQ6iEbqEA:9 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Received: from unknown (HELO lagos.xvx.ca) ([68.150.39.45]) by smtp-out-04.shaw.ca with ESMTP; 13 Jul 2013 18:46:06 -0600 Received: by lagos.xvx.ca (Postfix, from userid 1000) id 138BC8009323; Sat, 13 Jul 2013 18:46:06 -0600 (MDT) From: Adam Wolfe Gordon To: notmuch@notmuchmail.org Subject: [PATCH 3/3] test: Add simple tests for the add command Date: Sat, 13 Jul 2013 18:45:46 -0600 Message-Id: <1373762746-22308-4-git-send-email-awg+notmuch@xvx.ca> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1373762746-22308-1-git-send-email-awg+notmuch@xvx.ca> References: <1373762746-22308-1-git-send-email-awg+notmuch@xvx.ca> 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, 14 Jul 2013 00:46:15 -0000 --- test/insert | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/insert b/test/insert index 021edb6..eb23e02 100755 --- a/test/insert +++ b/test/insert @@ -18,6 +18,14 @@ gen_insert_msg() { "[body]=\"insert-message\"" } +gen_add_msg() { + generate_message \ + "[dir]=add-messages/cur" \ + "[subject]=\"add-subject\"" \ + "[body]=\"add-message\"" \ + "[id]=\"add-message\"" +} + test_expect_code 1 "Insert zero-length file" \ "notmuch insert < /dev/null" @@ -118,4 +126,31 @@ gen_insert_msg test_expect_code 1 "Insert message, create invalid subfolder" \ "notmuch insert --folder=../G --create-folder $gen_msg_filename" +gen_add_msg +tmp_filename=/tmp/$(basename $gen_msg_filename) +mv $gen_msg_filename $tmp_filename +notmuch add $tmp_filename +test_expect_code 1 "Add message from outside maildir returns 1" \ + "notmuch add $tmp_filename" + +test_begin_subtest "Add message from outside maildir does nothing" +output=$(notmuch count id:$gen_msg_id) +test_expect_equal "$output" "0" + +test_begin_subtest "Add message from inside maildir" +gen_add_msg +notmuch add $gen_msg_filename +output=$(notmuch count id:$gen_msg_id) +test_expect_equal "$output" "1" + +test_begin_subtest "Add duplicate message" +gen_add_msg +notmuch add "$gen_msg_filename" +output=$(notmuch search --output=files "id:$gen_msg_id" | wc -l) +test_expect_equal "$output" 2 + +test_begin_subtest "Adding duplicate message does not change tags" +output=$(notmuch search --format=json --output=tags "id:$gen_msg_id") +test_expect_equal_json "$output" '["inbox", "unread"]' + test_done -- 1.7.9.5