2 * Database routines intended only for testing, not exported from
5 * Copyright (c) 2012 David Bremner
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see http://www.gnu.org/licenses/ .
20 * Author: David Bremner <david@tethera.net>
23 #include "notmuch-private.h"
24 #include "database-test.h"
27 notmuch_database_add_stub_message (notmuch_database_t *notmuch,
28 const char *message_id,
33 notmuch_private_status_t private_status;
34 notmuch_message_t *message;
36 ret = _notmuch_database_ensure_writable (notmuch);
40 message = _notmuch_message_create_for_message_id (notmuch,
43 if (message == NULL) {
44 return COERCE_STATUS (private_status,
45 "Unexpected status value from _notmuch_message_create_for_message_id");
49 if (private_status != NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND)
50 return NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
52 _notmuch_message_add_term (message, "type", "mail");
55 ret = notmuch_message_freeze (message);
59 for (tag = tags; *tag; tag++) {
60 ret = notmuch_message_add_tag (message, *tag);
65 ret = notmuch_message_thaw (message);
70 return NOTMUCH_STATUS_SUCCESS;