Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 77 / 428e5ec59219751613409a272418fb4da790f9
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 DFABD431FC4\r
6         for <notmuch@notmuchmail.org>; Fri, 21 Jun 2013 22:47:50 -0700 (PDT)\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 xByu6NNuUaB0 for <notmuch@notmuchmail.org>;\r
17         Fri, 21 Jun 2013 22:47:44 -0700 (PDT)\r
18 Received: from mail-pb0-f41.google.com (mail-pb0-f41.google.com\r
19         [209.85.160.41]) (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 5165F431FAE\r
22         for <notmuch@notmuchmail.org>; Fri, 21 Jun 2013 22:47:26 -0700 (PDT)\r
23 Received: by mail-pb0-f41.google.com with SMTP id rp16so8734759pbb.0\r
24         for <notmuch@notmuchmail.org>; Fri, 21 Jun 2013 22:47:25 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
27         bh=cFI8tSe6Eyh8rSOCGhbSQ1elpywalxWY/JUiJJMe/y0=;\r
28         b=meZB3DjVptS635czg7TZr3pcFyc8UdBpAqaNja3huFKoRjd8gMZDk4699IWRPEqi++\r
29         Dz3DpHy0rtWtj6IZGYsF5DQz5Y4/3lm2zjGzoWpldaDFppu3OBIm/IJ3Thx87MDgkf7J\r
30         NNvgAARp1WkoUA8ISU1cWGgR1Sp/0l/YTeoLsq1ZEyAwfJyoAks6b9TXwoVh5IKdFCYI\r
31         Bu+cXhfu0TKrZqaEHR4NTGEvg/SENXSDQoZbQgSCTuWxFlvor6tZlr4ww9uJRcIPExRW\r
32         fO5VgzAUVdsRihgCXNEe6wBOQRy9oN5sZWq6AXMuyPlRfEfA5iS1EHTrZPqq9Fd3TOdw\r
33         TEtQ==\r
34 X-Received: by 10.66.182.166 with SMTP id ef6mr19696659pac.35.1371880045564;\r
35         Fri, 21 Jun 2013 22:47:25 -0700 (PDT)\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 ESMTPSA id fp2sm7857266pbb.36.2013.06.21.22.47.23\r
39         for <multiple recipients>\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Fri, 21 Jun 2013 22:47:24 -0700 (PDT)\r
42 From: Peter Wang <novalazy@gmail.com>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH v6 06/12] test: add tests for insert\r
45 Date: Sat, 22 Jun 2013 15:46:42 +1000\r
46 Message-Id: <1371880008-18312-7-git-send-email-novalazy@gmail.com>\r
47 X-Mailer: git-send-email 1.7.12.1\r
48 In-Reply-To: <1371880008-18312-1-git-send-email-novalazy@gmail.com>\r
49 References: <1371880008-18312-1-git-send-email-novalazy@gmail.com>\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Sat, 22 Jun 2013 05:47:51 -0000\r
63 \r
64 Add tests for new 'insert' command.\r
65 ---\r
66  test/insert       | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
67  test/notmuch-test |  1 +\r
68  2 files changed, 81 insertions(+)\r
69  create mode 100755 test/insert\r
70 \r
71 diff --git a/test/insert b/test/insert\r
72 new file mode 100755\r
73 index 0000000..b432a74\r
74 --- /dev/null\r
75 +++ b/test/insert\r
76 @@ -0,0 +1,80 @@\r
77 +#!/usr/bin/env bash\r
78 +test_description='"notmuch insert"'\r
79 +. ./test-lib.sh\r
80 +\r
81 +# Create directories and database before inserting.\r
82 +mkdir -p "$MAIL_DIR"/{cur,new,tmp}\r
83 +mkdir -p "$MAIL_DIR"/Drafts/{cur,new,tmp}\r
84 +notmuch new > /dev/null\r
85 +\r
86 +# We use generate_message to create the temporary message files.\r
87 +# They happen to be in the mail directory already but that is okay\r
88 +# since we do not call notmuch new hereafter.\r
89 +\r
90 +gen_insert_msg() {\r
91 +    generate_message \\r
92 +       "[subject]=\"insert-subject\"" \\r
93 +       "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \\r
94 +       "[body]=\"insert-message\""\r
95 +}\r
96 +\r
97 +test_expect_code 1 "Insert zero-length file" \\r
98 +    "notmuch insert < /dev/null"\r
99 +\r
100 +# This test is a proxy for other errors that may occur while trying to\r
101 +# add a message to the notmuch database, e.g. database locked.\r
102 +test_expect_code 0 "Insert non-message" \\r
103 +    "echo bad_message | notmuch insert"\r
104 +\r
105 +test_begin_subtest "Database empty so far"\r
106 +test_expect_equal "0" "`notmuch count --output=messages '*'`"\r
107 +\r
108 +test_begin_subtest "Insert message"\r
109 +gen_insert_msg\r
110 +notmuch insert < "$gen_msg_filename"\r
111 +cur_msg_filename=$(notmuch search --output=files "subject:insert-subject")\r
112 +test_expect_equal_file "$cur_msg_filename" "$gen_msg_filename"\r
113 +\r
114 +test_begin_subtest "Insert message adds default tags"\r
115 +output=$(notmuch show --format=json "subject:insert-subject")\r
116 +expected='[[[{\r
117 + "id": "'"${gen_msg_id}"'",\r
118 + "match": true,\r
119 + "excluded": false,\r
120 + "filename": "'"${cur_msg_filename}"'",\r
121 + "timestamp": 946728000,\r
122 + "date_relative": "2000-01-01",\r
123 + "tags": ["inbox","unread"],\r
124 + "headers": {\r
125 +  "Subject": "insert-subject",\r
126 +  "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
127 +  "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
128 +  "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},\r
129 + "body": [{"id": 1,\r
130 +  "content-type": "text/plain",\r
131 +  "content": "insert-message\n"}]},\r
132 + []]]]'\r
133 +test_expect_equal_json "$output" "$expected"\r
134 +\r
135 +test_begin_subtest "Insert duplicate message"\r
136 +notmuch insert +duptag -unread < "$gen_msg_filename"\r
137 +output=$(notmuch search --output=files "subject:insert-subject" | wc -l)\r
138 +test_expect_equal "$output" 2\r
139 +\r
140 +test_begin_subtest "Duplicate message does not change tags"\r
141 +output=$(notmuch search --format=json --output=tags "subject:insert-subject")\r
142 +test_expect_equal_json "$output" '["inbox", "unread"]'\r
143 +\r
144 +test_begin_subtest "Insert message, add tag"\r
145 +gen_insert_msg\r
146 +notmuch insert +custom < "$gen_msg_filename"\r
147 +output=$(notmuch count tag:custom)\r
148 +test_expect_equal "$output" "1"\r
149 +\r
150 +test_begin_subtest "Insert message, add/remove tags"\r
151 +gen_insert_msg\r
152 +notmuch insert +custom -unread < "$gen_msg_filename"\r
153 +output=$(notmuch count tag:custom NOT tag:unread)\r
154 +test_expect_equal "$output" "1"\r
155 +\r
156 +test_done\r
157 diff --git a/test/notmuch-test b/test/notmuch-test\r
158 index a0c47d4..6db7979 100755\r
159 --- a/test/notmuch-test\r
160 +++ b/test/notmuch-test\r
161 @@ -23,6 +23,7 @@ TESTS="\r
162    setup\r
163    new\r
164    count\r
165 +  insert\r
166    search\r
167    search-output\r
168    search-by-folder\r
169 -- \r
170 1.7.12.1\r
171 \r