Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 5a / a13311c722228f170c23654cec3e5f76ba1baa
1 Return-Path: <bremner@tethera.net>\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 A74E5431E84\r
6         for <notmuch@notmuchmail.org>; Sun,  2 Dec 2012 05:34:09 -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\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id yPHKwfOjD3hR for <notmuch@notmuchmail.org>;\r
16         Sun,  2 Dec 2012 05:34:05 -0800 (PST)\r
17 Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238])\r
18         (using TLSv1 with cipher AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id E5178431FAE\r
21         for <notmuch@notmuchmail.org>; Sun,  2 Dec 2012 05:33:54 -0800 (PST)\r
22 Received: from fctnnbsc30w-142167090129.dhcp-dynamic.fibreop.nb.bellaliant.net\r
23         ([142.167.90.129] helo=zancas.localnet)\r
24         by tesseract.cs.unb.ca with esmtpsa\r
25         (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72)\r
26         (envelope-from <bremner@tethera.net>)\r
27         id 1Tf9g0-0005w3-QC; Sun, 02 Dec 2012 09:33:54 -0400\r
28 Received: from bremner by zancas.localnet with local (Exim 4.80)\r
29         (envelope-from <bremner@tethera.net>)\r
30         id 1Tf9fv-0001ra-A5; Sun, 02 Dec 2012 09:33:39 -0400\r
31 From: david@tethera.net\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [patch v3 4/6] test: add database routines for testing\r
34 Date: Sun,  2 Dec 2012 09:33:22 -0400\r
35 Message-Id: <1354455204-6908-5-git-send-email-david@tethera.net>\r
36 X-Mailer: git-send-email 1.7.10.4\r
37 In-Reply-To: <1354455204-6908-1-git-send-email-david@tethera.net>\r
38 References: <1354455204-6908-1-git-send-email-david@tethera.net>\r
39 X-Spam_bar: -\r
40 Cc: David Bremner <bremner@debian.org>\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\r
44 List-Id: "Use and development of the notmuch mail system."\r
45         <notmuch.notmuchmail.org>\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
49 List-Post: <mailto:notmuch@notmuchmail.org>\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
53 X-List-Received-Date: Sun, 02 Dec 2012 13:34:10 -0000\r
54 \r
55 From: David Bremner <bremner@debian.org>\r
56 \r
57 Initially, provide a way to create "stub" messages in the notmuch\r
58 database without corresponding files.  This is essentially cut and\r
59 paste from lib/database.cc. This is a seperate file since we don't\r
60 want to export these symbols from libnotmuch or bloat the library with\r
61 non-exported code.\r
62 ---\r
63  test/Makefile.local  |    1 +\r
64  test/database-test.c |   71 ++++++++++++++++++++++++++++++++++++++++++++++++++\r
65  test/database-test.h |   21 +++++++++++++++\r
66  3 files changed, 93 insertions(+)\r
67  create mode 100644 test/database-test.c\r
68  create mode 100644 test/database-test.h\r
69 \r
70 diff --git a/test/Makefile.local b/test/Makefile.local\r
71 index 8da4c56..8479f91 100644\r
72 --- a/test/Makefile.local\r
73 +++ b/test/Makefile.local\r
74 @@ -45,5 +45,6 @@ CLEAN := $(CLEAN) $(dir)/smtp-dummy $(dir)/smtp-dummy.o \\r
75          $(dir)/symbol-test $(dir)/symbol-test.o \\r
76          $(dir)/arg-test $(dir)/arg-test.o \\r
77          $(dir)/hex-xcode $(dir)/hex-xcode.o \\r
78 +        $(dir)/database-test.o \\r
79          $(dir)/parse-time $(dir)/parse-time.o \\r
80          $(dir)/corpus.mail $(dir)/test-results $(dir)/tmp.*\r
81 diff --git a/test/database-test.c b/test/database-test.c\r
82 new file mode 100644\r
83 index 0000000..b8c3a67\r
84 --- /dev/null\r
85 +++ b/test/database-test.c\r
86 @@ -0,0 +1,71 @@\r
87 +/*\r
88 + * Database routines intended only for testing, not exported from\r
89 + * library.\r
90 + *\r
91 + * Copyright (c) 2012 David Bremner\r
92 + *\r
93 + * This program is free software: you can redistribute it and/or modify\r
94 + * it under the terms of the GNU General Public License as published by\r
95 + * the Free Software Foundation, either version 3 of the License, or\r
96 + * (at your option) any later version.\r
97 + *\r
98 + * This program is distributed in the hope that it will be useful,\r
99 + * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
100 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
101 + * GNU General Public License for more details.\r
102 + *\r
103 + * You should have received a copy of the GNU General Public License\r
104 + * along with this program.  If not, see http://www.gnu.org/licenses/ .\r
105 + *\r
106 + * Author: David Bremner <david@tethera.net>\r
107 + */\r
108 +\r
109 +#include "notmuch-private.h"\r
110 +#include "database-test.h"\r
111 +\r
112 +notmuch_status_t\r
113 +notmuch_database_add_stub_message (notmuch_database_t *notmuch,\r
114 +                                  const char *message_id,\r
115 +                                  const char **tags)\r
116 +{\r
117 +    const char **tag;\r
118 +    notmuch_status_t ret;\r
119 +    notmuch_private_status_t private_status;\r
120 +    notmuch_message_t *message;\r
121 +\r
122 +    ret = _notmuch_database_ensure_writable (notmuch);\r
123 +    if (ret)\r
124 +       return ret;\r
125 +\r
126 +    message = _notmuch_message_create_for_message_id (notmuch,\r
127 +                                                     message_id,\r
128 +                                                     &private_status);\r
129 +    if (message == NULL) {\r
130 +       return COERCE_STATUS (private_status,\r
131 +                             "Unexpected status value from _notmuch_message_create_for_message_id");\r
132 +\r
133 +    }\r
134 +\r
135 +    if (private_status != NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND)\r
136 +       return NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;\r
137 +\r
138 +    _notmuch_message_add_term (message, "type", "mail");\r
139 +\r
140 +    if (tags) {\r
141 +       ret = notmuch_message_freeze (message);\r
142 +       if (ret)\r
143 +           return ret;\r
144 +\r
145 +       for (tag = tags; *tag; tag++) {\r
146 +           ret = notmuch_message_add_tag (message, *tag);\r
147 +           if (ret)\r
148 +               return ret;\r
149 +       }\r
150 +\r
151 +       ret = notmuch_message_thaw (message);\r
152 +       if (ret)\r
153 +           return ret;\r
154 +    }\r
155 +\r
156 +    return NOTMUCH_STATUS_SUCCESS;\r
157 +}\r
158 diff --git a/test/database-test.h b/test/database-test.h\r
159 new file mode 100644\r
160 index 0000000..84f7988\r
161 --- /dev/null\r
162 +++ b/test/database-test.h\r
163 @@ -0,0 +1,21 @@\r
164 +#ifndef _DATABASE_TEST_H\r
165 +#define _DATABASE_TEST_H\r
166 +/* Add a new stub message to the given notmuch database.\r
167 + *\r
168 + * At least the following return values are possible:\r
169 + *\r
170 + * NOTMUCH_STATUS_SUCCESS: Message successfully added to database.\r
171 + *\r
172 + * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: Message has the same message\r
173 + *     ID as another message already in the database.\r
174 + *\r
175 + * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only\r
176 + *     mode so no message can be added.\r
177 + */\r
178 +\r
179 +notmuch_status_t\r
180 +notmuch_database_add_stub_message (notmuch_database_t *database,\r
181 +                                  const char *message_id,\r
182 +                                  const char **tag_list);\r
183 +\r
184 +#endif\r
185 -- \r
186 1.7.10.4\r
187 \r