unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Cc: David Bremner <david@tethera.net>
Subject: [PATCH 1/8] test: regression test for n_t_get_thread_id
Date: Fri, 24 Jul 2020 08:13:59 -0300	[thread overview]
Message-ID: <20200724111406.177593-2-david@tethera.net> (raw)
In-Reply-To: <20200724111406.177593-1-david@tethera.net>

This is just cached data, so as long as we don't prematurely free
anything, it should be fine.
---
 test/T568-lib-thread.sh | 63 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100755 test/T568-lib-thread.sh

diff --git a/test/T568-lib-thread.sh b/test/T568-lib-thread.sh
new file mode 100755
index 00000000..00755834
--- /dev/null
+++ b/test/T568-lib-thread.sh
@@ -0,0 +1,63 @@
+#!/usr/bin/env bash
+test_description="API tests for notmuch_thread_*"
+
+. $(dirname "$0")/test-lib.sh || exit 1
+
+add_email_corpus
+
+test_begin_subtest "building database"
+test_expect_success "NOTMUCH_NEW"
+
+cat <<'EOF' > c_tail
+   if (stat) {
+       const char *stat_str = notmuch_database_status_string (db);
+       if (stat_str)
+           fputs (stat_str, stderr);
+    }
+
+}
+EOF
+
+cat <<EOF > c_head
+#include <stdio.h>
+#include <notmuch.h>
+#include <notmuch-test.h>
+int main (int argc, char** argv)
+{
+   notmuch_database_t *db;
+   notmuch_status_t stat;
+   char *msg = NULL;
+   notmuch_thread_t *thread = NULL;
+   notmuch_threads_t *threads = NULL;
+   notmuch_query_t *query = NULL;
+   const char *id = "thread:0000000000000009";
+
+   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);
+   }
+
+   query = notmuch_query_create (db, id);
+   EXPECT0(notmuch_query_search_threads (query, &threads));
+   thread = notmuch_threads_get (threads);
+   EXPECT0(notmuch_database_close (db));
+EOF
+
+test_begin_subtest "get thread-id from closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+    {
+        const char *id2;
+        id2 = notmuch_thread_get_thread_id (thread);
+        printf("%d\n%s\n", thread != NULL, id2);
+    }
+EOF
+cat <<EOF > EXPECTED
+== stdout ==
+1
+0000000000000009
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_done
-- 
2.27.0

  reply	other threads:[~2020-07-24 11:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-24 11:13 batch 9: API cleanup for exception handling David Bremner
2020-07-24 11:13 ` David Bremner [this message]
2020-07-24 11:14 ` [PATCH 2/8] test: add regression test for n_thread_get_total_{messages,files} David Bremner
2020-07-24 11:14 ` [PATCH 3/8] test: add regression tests for n_thread_get_toplevel_messages David Bremner
2020-07-24 11:14 ` [PATCH 4/8] test: add regression test for n_t_get_messages David Bremner
2020-07-24 11:14 ` [PATCH 5/8] test: add regression tests for n_t_get_{authors, subject} David Bremner
2020-07-24 11:14 ` [PATCH 6/8] test: add regression tests for oldest and newest dates David Bremner
2020-07-24 11:14 ` [PATCH 7/8] test: regression test for n_thread_get_tags David Bremner
2020-07-24 11:14 ` [PATCH 8/8] test: destroy thread from closed database David Bremner
2020-07-31 12:15 ` batch 9: 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=20200724111406.177593-2-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).