From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Cc: David Bremner <david@tethera.net>
Subject: [PATCH 3/8] test: add regression tests for n_thread_get_toplevel_messages
Date: Fri, 24 Jul 2020 08:14:01 -0300 [thread overview]
Message-ID: <20200724111406.177593-4-david@tethera.net> (raw)
In-Reply-To: <20200724111406.177593-1-david@tethera.net>
Include a test for the previously omitted non-trivial code path for
notmuch_thread_get_replies.
---
test/T566-lib-message.sh | 1 -
test/T568-lib-thread.sh | 80 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+), 1 deletion(-)
diff --git a/test/T566-lib-message.sh b/test/T566-lib-message.sh
index 7a351725..4c9fc0df 100755
--- a/test/T566-lib-message.sh
+++ b/test/T566-lib-message.sh
@@ -93,7 +93,6 @@ A Xapian exception occurred at lib/message.cc:XXX: Database has been closed
EOF
test_expect_equal_file EXPECTED OUTPUT
-# XXX TODO: test on a message from notmuch_thread_get_toplevel_messages
# XXX this test only tests the trivial code path
test_begin_subtest "Handle getting replies from closed database"
cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
diff --git a/test/T568-lib-thread.sh b/test/T568-lib-thread.sh
index 5816cfbc..4703950b 100755
--- a/test/T568-lib-thread.sh
+++ b/test/T568-lib-thread.sh
@@ -92,4 +92,84 @@ cat <<EOF > EXPECTED
EOF
test_expect_equal_file EXPECTED OUTPUT
+test_begin_subtest "get top level messages with closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+ {
+ notmuch_messages_t *messages;
+ messages = notmuch_thread_get_toplevel_messages (thread);
+ printf("%d\n%d\n", thread != NULL, messages != NULL);
+ }
+EOF
+cat <<EOF > EXPECTED
+== stdout ==
+1
+1
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "iterate over level messages with closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+ {
+ notmuch_messages_t *messages;
+ for (messages = notmuch_thread_get_toplevel_messages (thread);
+ notmuch_messages_valid (messages);
+ notmuch_messages_move_to_next (messages)) {
+ notmuch_message_t *message = notmuch_messages_get (messages);
+ const char *mid = notmuch_message_get_message_id (message);
+ printf("%s\n", mid);
+ }
+ }
+EOF
+cat <<EOF > EXPECTED
+== stdout ==
+20091117190054.GU3165@dottiness.seas.harvard.edu
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "iterate over level messages with closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+ {
+ notmuch_messages_t *messages;
+ for (messages = notmuch_thread_get_toplevel_messages (thread);
+ notmuch_messages_valid (messages);
+ notmuch_messages_move_to_next (messages)) {
+ notmuch_message_t *message = notmuch_messages_get (messages);
+ const char *mid = notmuch_message_get_message_id (message);
+ printf("%s\n", mid);
+ }
+ }
+EOF
+cat <<EOF > EXPECTED
+== stdout ==
+20091117190054.GU3165@dottiness.seas.harvard.edu
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "iterate over replies with closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+ {
+ notmuch_messages_t *messages = notmuch_thread_get_toplevel_messages (thread);
+ notmuch_message_t *message = notmuch_messages_get (messages);
+ notmuch_messages_t *replies;
+ for (replies = notmuch_message_get_replies (message);
+ notmuch_messages_valid (replies);
+ notmuch_messages_move_to_next (replies)) {
+ notmuch_message_t *message = notmuch_messages_get (replies);
+ const char *mid = notmuch_message_get_message_id (message);
+
+ printf("%s\n", mid);
+ }
+ }
+EOF
+cat <<EOF > EXPECTED
+== stdout ==
+87iqd9rn3l.fsf@vertex.dottedmag
+87ocn0qh6d.fsf@yoom.home.cworth.org
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
test_done
--
2.27.0
next prev parent 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 ` [PATCH 1/8] test: regression test for n_t_get_thread_id David Bremner
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 ` David Bremner [this message]
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-4-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).