aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2020-07-22 07:51:26 -0300
committerDavid Bremner <david@tethera.net>2020-07-29 12:20:30 -0300
commit451c0ce3fce6141ee658153a074b78a2b0e24955 (patch)
tree3125f6b84a95c8831bd56d94a63f0c50a6c6410a
parent0a4c6cdeb118e68f2fa73a4b90b2fa74a06e88ab (diff)
test: regression tests for n_q_count_{messages, threads}
At least these exceptions are caught.
-rwxr-xr-xtest/T564-lib-query.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/T564-lib-query.sh b/test/T564-lib-query.sh
index dda32be7..745d28a4 100755
--- a/test/T564-lib-query.sh
+++ b/test/T564-lib-query.sh
@@ -185,4 +185,50 @@ Query string was: id:1258471718-6781-1-git-send-email-dottedmag@dottedmag.net
EOF
test_expect_equal_file EXPECTED OUTPUT
+test_begin_subtest "count messages on 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";
+ unsigned int count;
+
+ query = notmuch_query_create (db, str);
+ EXPECT0(notmuch_database_close (db));
+ stat = notmuch_query_count_messages (query, &count);
+
+ printf("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
+ }
+EOF
+cat <<EOF > EXPECTED
+== stdout ==
+1
+== stderr ==
+A Xapian exception occurred performing query: Database has been closed
+Query string was: id:1258471718-6781-1-git-send-email-dottedmag@dottedmag.net
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "count threads on 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";
+ unsigned int count;
+
+ query = notmuch_query_create (db, str);
+ EXPECT0(notmuch_database_close (db));
+ stat = notmuch_query_count_threads (query, &count);
+
+ printf("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
+ }
+EOF
+cat <<EOF > EXPECTED
+== stdout ==
+1
+== stderr ==
+A Xapian exception occurred performing query: Database has been closed
+Query string was: id:1258471718-6781-1-git-send-email-dottedmag@dottedmag.net
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
test_done