From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Cc: David Bremner <david@tethera.net>
Subject: [PATCH 02/10] test: add regression test for n_q_{create,_get_query_string}
Date: Wed, 22 Jul 2020 07:51:19 -0300 [thread overview]
Message-ID: <20200722105127.373054-3-david@tethera.net> (raw)
In-Reply-To: <20200722105127.373054-1-david@tethera.net>
Start a new file of tests, to keep to the (emerging) scheme of one
notmuch_foo group per file
---
test/T564-lib-query.sh | 61 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
create mode 100755 test/T564-lib-query.sh
diff --git a/test/T564-lib-query.sh b/test/T564-lib-query.sh
new file mode 100755
index 00000000..103870a6
--- /dev/null
+++ b/test/T564-lib-query.sh
@@ -0,0 +1,61 @@
+#!/usr/bin/env bash
+test_description="notmuch_database_* API"
+
+. $(dirname "$0")/test-lib.sh || exit 1
+
+add_email_corpus
+
+test_begin_subtest "building database"
+test_expect_success "NOTMUCH_NEW"
+
+cat <<EOF > c_head
+#include <stdio.h>
+#include <notmuch.h>
+#include <notmuch-test.h>
+#include <talloc.h>
+int main (int argc, char** argv)
+{
+ notmuch_database_t *db;
+ notmuch_status_t stat;
+ char *msg = NULL;
+
+ stat = notmuch_database_open_verbose (argv[1], NOTMUCH_DATABASE_MODE_READ_WRITE, &db, &msg);
+ if (stat != NOTMUCH_STATUS_SUCCESS) {
+ fprintf (stderr, "error opening database: %d %s\n", stat, msg ? msg : "");
+ exit (1);
+ }
+EOF
+
+cat <<'EOF' > c_tail
+ if (stat) {
+ const char *stat_str = notmuch_database_status_string (db);
+ if (stat_str)
+ fputs (stat_str, stderr);
+ }
+
+}
+EOF
+
+test_begin_subtest "roundtrip query string with closed db"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+ {
+ notmuch_query_t *query;
+ const char *str = "id:1258471718-6781-1-git-send-email-dottedmag@dottedmag.net";
+ const char *ret;
+
+ EXPECT0(notmuch_database_close (db));
+ query = notmuch_query_create (db, str);
+ ret = notmuch_query_get_query_string (query);
+
+ printf("%s\n%s\n", str, ret);
+ }
+EOF
+cat <<EOF > EXPECTED
+== stdout ==
+id:1258471718-6781-1-git-send-email-dottedmag@dottedmag.net
+id:1258471718-6781-1-git-send-email-dottedmag@dottedmag.net
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_done
--
2.27.0
next prev parent reply other threads:[~2020-07-22 10:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-22 10:51 batch 8, API cleanup for exception handling David Bremner
2020-07-22 10:51 ` [PATCH 01/10] test: move notmuch_message_* tests to their own file David Bremner
2020-07-22 10:51 ` David Bremner [this message]
2020-07-22 10:51 ` [PATCH 03/10] test: regression test for notmuch_query_get_database David Bremner
2020-07-22 10:51 ` [PATCH 04/10] test: regression test for set_omit_excluded David Bremner
2020-07-22 10:51 ` [PATCH 05/10] test: regression test for n_q_{set, get}_sort David Bremner
2020-07-22 10:51 ` [PATCH 06/10] test: add regression test for n_q_add_tag_exclude David Bremner
2020-07-22 10:51 ` [PATCH 07/10] test: regression test for n_q_search_threads David Bremner
2020-07-22 10:51 ` [PATCH 08/10] test: regression test for n_q_search_messages David Bremner
2020-07-22 10:51 ` [PATCH 09/10] test: regression tests for n_q_count_{messages, threads} David Bremner
2020-07-22 10:51 ` [PATCH 10/10] test: regression test for notmuch_query_destroy David Bremner
2020-07-29 15:47 ` batch 8, API cleanup for exception handling David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200722105127.373054-3-david@tethera.net \
--to=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).