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