[PATCH v4 06/12] test: add tests for insert
authorPeter Wang <novalazy@gmail.com>
Thu, 24 Jan 2013 12:08:02 +0000 (23:08 +1100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:53:22 +0000 (09:53 -0800)
c2/ab3d596bd815f075d61877a7444212207f3907 [new file with mode: 0644]

diff --git a/c2/ab3d596bd815f075d61877a7444212207f3907 b/c2/ab3d596bd815f075d61877a7444212207f3907
new file mode 100644 (file)
index 0000000..665fa0d
--- /dev/null
@@ -0,0 +1,159 @@
+Return-Path: <novalazy@gmail.com>\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 CB62D431FAE\r
+       for <notmuch@notmuchmail.org>; Thu, 24 Jan 2013 04:09:58 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 QnUGqPD90vzr for <notmuch@notmuchmail.org>;\r
+       Thu, 24 Jan 2013 04:09:57 -0800 (PST)\r
+Received: from mail-da0-f47.google.com (mail-da0-f47.google.com\r
+       [209.85.210.47]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 709A9431FDB\r
+       for <notmuch@notmuchmail.org>; Thu, 24 Jan 2013 04:09:45 -0800 (PST)\r
+Received: by mail-da0-f47.google.com with SMTP id s35so4220585dak.6\r
+       for <notmuch@notmuchmail.org>; Thu, 24 Jan 2013 04:09:44 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
+       :references; bh=NrPnZPykLK2TpFCynS09JPv/TJDegodV3DD7IJ9F7Lo=;\r
+       b=uh5Jzl3v0z70vXN0uOUBekzUfaqxQU7mO5WXrmY82633Op9wpVA0EIUODGq0cw5i9G\r
+       3j7gApSlEkhd9Z+LJZXt1QAocKp8dvHsI8uR8ozyZ86jtEpJ/xwmFYmwHoGK8nf6kL5f\r
+       PsmuBoHof7yUbp+v/CuUXEjWcTUHx0iSlrSDVXkIPyZR30UyM2y2ned/K0EP6VKWPBBN\r
+       rrh1NKvfllxfMNBj+rpNJBcvckE7NYEsyUXAkggq53fNa0RcrK+qT+zK8oHh0VY1qznB\r
+       klWw76VRkb4ewhpq29fpWn7s559WPtVIEvUDhRHtwT4/AoZx16drPSVtZgzOx83thF+K\r
+       rQRw==\r
+X-Received: by 10.66.86.71 with SMTP id n7mr3939264paz.77.1359029384631;\r
+       Thu, 24 Jan 2013 04:09:44 -0800 (PST)\r
+Received: from localhost (215.42.233.220.static.exetel.com.au.\r
+       [220.233.42.215])\r
+       by mx.google.com with ESMTPS id hs2sm14784883pbc.22.2013.01.24.04.09.42\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Thu, 24 Jan 2013 04:09:43 -0800 (PST)\r
+From: Peter Wang <novalazy@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v4 06/12] test: add tests for insert\r
+Date: Thu, 24 Jan 2013 23:08:02 +1100\r
+Message-Id: <1359029288-12132-7-git-send-email-novalazy@gmail.com>\r
+X-Mailer: git-send-email 1.7.12.1\r
+In-Reply-To: <1359029288-12132-1-git-send-email-novalazy@gmail.com>\r
+References: <1359029288-12132-1-git-send-email-novalazy@gmail.com>\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: Thu, 24 Jan 2013 12:09:59 -0000\r
+\r
+Add tests for new 'insert' command.\r
+---\r
+ test/insert       | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ test/notmuch-test |  1 +\r
+ 2 files changed, 70 insertions(+)\r
+ create mode 100755 test/insert\r
+\r
+diff --git a/test/insert b/test/insert\r
+new file mode 100755\r
+index 0000000..d880af9\r
+--- /dev/null\r
++++ b/test/insert\r
+@@ -0,0 +1,69 @@\r
++#!/usr/bin/env bash\r
++test_description='"notmuch insert"'\r
++. ./test-lib.sh\r
++\r
++# Create directories and database before inserting.\r
++mkdir -p "$MAIL_DIR"/{cur,new,tmp}\r
++mkdir -p "$MAIL_DIR"/Drafts/{cur,new,tmp}\r
++notmuch new > /dev/null\r
++\r
++# We use generate_message to create the temporary message files.\r
++# They happen to be in the mail directory already but that is okay\r
++# since we do not call notmuch new hereafter.\r
++\r
++gen_insert_msg() {\r
++    generate_message \\r
++      "[subject]=\"insert-subject\"" \\r
++      "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \\r
++      "[body]=\"insert-message\""\r
++}\r
++\r
++test_begin_subtest "Insert message, copied exactly"\r
++gen_insert_msg\r
++notmuch insert < "$gen_msg_filename"\r
++cur_msg_filename=$(notmuch search --output=files "subject:insert-subject")\r
++test_expect_equal_file "$cur_msg_filename" "$gen_msg_filename"\r
++\r
++test_begin_subtest "Insert message, default tags"\r
++output=$(notmuch show --format=json "subject:insert-subject")\r
++expected='[[[{\r
++ "id": "'"${gen_msg_id}"'",\r
++ "match": true,\r
++ "excluded": false,\r
++ "filename": "'"${cur_msg_filename}"'",\r
++ "timestamp": 946728000,\r
++ "date_relative": "2000-01-01",\r
++ "tags": ["inbox","unread"],\r
++ "headers": {\r
++  "Subject": "insert-subject",\r
++  "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
++  "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
++  "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},\r
++ "body": [{"id": 1,\r
++  "content-type": "text/plain",\r
++  "content": "insert-message\n"}]},\r
++ []]]]'\r
++test_expect_equal_json "$output" "$expected"\r
++\r
++test_begin_subtest "Insert message, duplicate message"\r
++notmuch insert +duptag -unread < "$gen_msg_filename"\r
++output=$(notmuch search --output=files "subject:insert-subject" | wc -l)\r
++test_expect_equal "$output" 2\r
++\r
++test_begin_subtest "Insert message, duplicate message does not change tags"\r
++output=$(notmuch search --format=json --output=tags "subject:insert-subject")\r
++test_expect_equal_json "$output" '["inbox", "unread"]'\r
++\r
++test_begin_subtest "Insert message, add tag"\r
++gen_insert_msg\r
++notmuch insert +custom < "$gen_msg_filename"\r
++output=$(notmuch count tag:custom)\r
++test_expect_equal "$output" "1"\r
++\r
++test_begin_subtest "Insert message, add/remove tag"\r
++gen_insert_msg\r
++notmuch insert +custom -unread < "$gen_msg_filename"\r
++output=$(notmuch count tag:custom NOT tag:unread)\r
++test_expect_equal "$output" "1"\r
++\r
++test_done\r
+diff --git a/test/notmuch-test b/test/notmuch-test\r
+index ca9c3dc..6952f0a 100755\r
+--- a/test/notmuch-test\r
++++ b/test/notmuch-test\r
+@@ -22,6 +22,7 @@ TESTS="\r
+   config\r
+   new\r
+   count\r
++  insert\r
+   search\r
+   search-output\r
+   search-by-folder\r
+-- \r
+1.7.12.1\r
+\r