Re: [PATCH] completion: fail silently if _init_completion is not found
[notmuch-archives.git] / f9 / 3fc805c4f3465a839903cdd6621cd137dedb0e
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 6F15D431FC3\r
6         for <notmuch@notmuchmail.org>; Sat, 22 Jun 2013 21:24: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 Mw0ZsCeHxORe for <notmuch@notmuchmail.org>;\r
17         Sat, 22 Jun 2013 21:24:44 -0700 (PDT)\r
18 Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com\r
19         [209.85.220.53]) (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 1832E431FD9\r
22         for <notmuch@notmuchmail.org>; Sat, 22 Jun 2013 21:24:27 -0700 (PDT)\r
23 Received: by mail-pa0-f53.google.com with SMTP id tj12so9508224pac.26\r
24         for <notmuch@notmuchmail.org>; Sat, 22 Jun 2013 21:24:26 -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=Z7yPj4I9a7Z8EW7liAcAlvL7QJpONWfU6oIaWMWOdO8a11eDcjxV3ZDkbYfOlqjL4A\r
29         TI1b8KIOcRnYhq6L7YodrD0JTLIBdViQOvJ/n3rJhT8PptrXNjZb/SvgREKu21MQPfVL\r
30         EPpWMnpayf3w4fBiR4xY7z19nCYHbbB6MzerfsKUs7BDjK+R0Rvi7nPyAUvoSglIlw1U\r
31         iM70KtYyUFOXWw3DMa2ogiFkW+GvVVB8xLNd/t9h/NjTfPyflQk69TegqFYLicuJdbqR\r
32         mELJLfh0+zPf2udRXBlKiJdeOi6WOsQmp6aGVH13XvnG/aEQ1hFDAQ3vypVVslD6VADS\r
33         d+UQ==\r
34 X-Received: by 10.68.163.165 with SMTP id yj5mr18664245pbb.141.1371961466406; \r
35         Sat, 22 Jun 2013 21:24:26 -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 kc8sm5959463pbc.18.2013.06.22.21.24.24\r
39         for <multiple recipients>\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Sat, 22 Jun 2013 21:24:25 -0700 (PDT)\r
42 From: Peter Wang <novalazy@gmail.com>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH v7 06/12] test: add tests for insert\r
45 Date: Sun, 23 Jun 2013 14:23:59 +1000\r
46 Message-Id: <1371961445-15182-7-git-send-email-novalazy@gmail.com>\r
47 X-Mailer: git-send-email 1.7.12.1\r
48 In-Reply-To: <1371961445-15182-1-git-send-email-novalazy@gmail.com>\r
49 References: <1371961445-15182-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: Sun, 23 Jun 2013 04:24:50 -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