Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / c2 / ab3d596bd815f075d61877a7444212207f3907
1 Return-Path: <novalazy@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id CB62D431FAE\r
6         for <notmuch@notmuchmail.org>; Thu, 24 Jan 2013 04:09:58 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id QnUGqPD90vzr for <notmuch@notmuchmail.org>;\r
17         Thu, 24 Jan 2013 04:09:57 -0800 (PST)\r
18 Received: from mail-da0-f47.google.com (mail-da0-f47.google.com\r
19         [209.85.210.47]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 709A9431FDB\r
22         for <notmuch@notmuchmail.org>; Thu, 24 Jan 2013 04:09:45 -0800 (PST)\r
23 Received: by mail-da0-f47.google.com with SMTP id s35so4220585dak.6\r
24         for <notmuch@notmuchmail.org>; Thu, 24 Jan 2013 04:09:44 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26         h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
27         :references; bh=NrPnZPykLK2TpFCynS09JPv/TJDegodV3DD7IJ9F7Lo=;\r
28         b=uh5Jzl3v0z70vXN0uOUBekzUfaqxQU7mO5WXrmY82633Op9wpVA0EIUODGq0cw5i9G\r
29         3j7gApSlEkhd9Z+LJZXt1QAocKp8dvHsI8uR8ozyZ86jtEpJ/xwmFYmwHoGK8nf6kL5f\r
30         PsmuBoHof7yUbp+v/CuUXEjWcTUHx0iSlrSDVXkIPyZR30UyM2y2ned/K0EP6VKWPBBN\r
31         rrh1NKvfllxfMNBj+rpNJBcvckE7NYEsyUXAkggq53fNa0RcrK+qT+zK8oHh0VY1qznB\r
32         klWw76VRkb4ewhpq29fpWn7s559WPtVIEvUDhRHtwT4/AoZx16drPSVtZgzOx83thF+K\r
33         rQRw==\r
34 X-Received: by 10.66.86.71 with SMTP id n7mr3939264paz.77.1359029384631;\r
35         Thu, 24 Jan 2013 04:09:44 -0800 (PST)\r
36 Received: from localhost (215.42.233.220.static.exetel.com.au.\r
37         [220.233.42.215])\r
38         by mx.google.com with ESMTPS id hs2sm14784883pbc.22.2013.01.24.04.09.42\r
39         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
40         Thu, 24 Jan 2013 04:09:43 -0800 (PST)\r
41 From: Peter Wang <novalazy@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH v4 06/12] test: add tests for insert\r
44 Date: Thu, 24 Jan 2013 23:08:02 +1100\r
45 Message-Id: <1359029288-12132-7-git-send-email-novalazy@gmail.com>\r
46 X-Mailer: git-send-email 1.7.12.1\r
47 In-Reply-To: <1359029288-12132-1-git-send-email-novalazy@gmail.com>\r
48 References: <1359029288-12132-1-git-send-email-novalazy@gmail.com>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Thu, 24 Jan 2013 12:09:59 -0000\r
62 \r
63 Add tests for new 'insert' command.\r
64 ---\r
65  test/insert       | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
66  test/notmuch-test |  1 +\r
67  2 files changed, 70 insertions(+)\r
68  create mode 100755 test/insert\r
69 \r
70 diff --git a/test/insert b/test/insert\r
71 new file mode 100755\r
72 index 0000000..d880af9\r
73 --- /dev/null\r
74 +++ b/test/insert\r
75 @@ -0,0 +1,69 @@\r
76 +#!/usr/bin/env bash\r
77 +test_description='"notmuch insert"'\r
78 +. ./test-lib.sh\r
79 +\r
80 +# Create directories and database before inserting.\r
81 +mkdir -p "$MAIL_DIR"/{cur,new,tmp}\r
82 +mkdir -p "$MAIL_DIR"/Drafts/{cur,new,tmp}\r
83 +notmuch new > /dev/null\r
84 +\r
85 +# We use generate_message to create the temporary message files.\r
86 +# They happen to be in the mail directory already but that is okay\r
87 +# since we do not call notmuch new hereafter.\r
88 +\r
89 +gen_insert_msg() {\r
90 +    generate_message \\r
91 +       "[subject]=\"insert-subject\"" \\r
92 +       "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \\r
93 +       "[body]=\"insert-message\""\r
94 +}\r
95 +\r
96 +test_begin_subtest "Insert message, copied exactly"\r
97 +gen_insert_msg\r
98 +notmuch insert < "$gen_msg_filename"\r
99 +cur_msg_filename=$(notmuch search --output=files "subject:insert-subject")\r
100 +test_expect_equal_file "$cur_msg_filename" "$gen_msg_filename"\r
101 +\r
102 +test_begin_subtest "Insert message, default tags"\r
103 +output=$(notmuch show --format=json "subject:insert-subject")\r
104 +expected='[[[{\r
105 + "id": "'"${gen_msg_id}"'",\r
106 + "match": true,\r
107 + "excluded": false,\r
108 + "filename": "'"${cur_msg_filename}"'",\r
109 + "timestamp": 946728000,\r
110 + "date_relative": "2000-01-01",\r
111 + "tags": ["inbox","unread"],\r
112 + "headers": {\r
113 +  "Subject": "insert-subject",\r
114 +  "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
115 +  "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
116 +  "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},\r
117 + "body": [{"id": 1,\r
118 +  "content-type": "text/plain",\r
119 +  "content": "insert-message\n"}]},\r
120 + []]]]'\r
121 +test_expect_equal_json "$output" "$expected"\r
122 +\r
123 +test_begin_subtest "Insert message, duplicate message"\r
124 +notmuch insert +duptag -unread < "$gen_msg_filename"\r
125 +output=$(notmuch search --output=files "subject:insert-subject" | wc -l)\r
126 +test_expect_equal "$output" 2\r
127 +\r
128 +test_begin_subtest "Insert message, duplicate message does not change tags"\r
129 +output=$(notmuch search --format=json --output=tags "subject:insert-subject")\r
130 +test_expect_equal_json "$output" '["inbox", "unread"]'\r
131 +\r
132 +test_begin_subtest "Insert message, add tag"\r
133 +gen_insert_msg\r
134 +notmuch insert +custom < "$gen_msg_filename"\r
135 +output=$(notmuch count tag:custom)\r
136 +test_expect_equal "$output" "1"\r
137 +\r
138 +test_begin_subtest "Insert message, add/remove tag"\r
139 +gen_insert_msg\r
140 +notmuch insert +custom -unread < "$gen_msg_filename"\r
141 +output=$(notmuch count tag:custom NOT tag:unread)\r
142 +test_expect_equal "$output" "1"\r
143 +\r
144 +test_done\r
145 diff --git a/test/notmuch-test b/test/notmuch-test\r
146 index ca9c3dc..6952f0a 100755\r
147 --- a/test/notmuch-test\r
148 +++ b/test/notmuch-test\r
149 @@ -22,6 +22,7 @@ TESTS="\r
150    config\r
151    new\r
152    count\r
153 +  insert\r
154    search\r
155    search-output\r
156    search-by-folder\r
157 -- \r
158 1.7.12.1\r
159 \r