[PATCH 11/13] test: regression test for traversing config list with closed db

Subject: [PATCH 11/13] test: regression test for traversing config list with closed db

Date: Sun, 26 Jul 2020 08:59:29 -0300

To: notmuch@notmuchmail.org

Cc: David Bremner

From: David Bremner


Also mention error return in API docs
---
 lib/notmuch.h          |  1 +
 test/T590-libconfig.sh | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/lib/notmuch.h b/lib/notmuch.h
index d52fa976..1fe62914 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -2291,6 +2291,7 @@ notmuch_config_list_key (notmuch_config_list_t *config_list);
  * next call to notmuch_config_list_value or notmuch config_list_destroy
  *
  * @since libnotmuch 4.4 (notmuch 0.23)
+ * @retval NULL for errors
  */
 const char *
 notmuch_config_list_value (notmuch_config_list_t *config_list);
diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
index 602fad0b..360e45b0 100755
--- a/test/T590-libconfig.sh
+++ b/test/T590-libconfig.sh
@@ -100,6 +100,28 @@ zzzafter afterval
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "notmuch_database_get_config_list: all pairs (closed db)"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+   notmuch_config_list_t *list;
+   EXPECT0(notmuch_database_get_config_list (db, "", &list));
+   EXPECT0(notmuch_database_close (db));
+   for (; notmuch_config_list_valid (list); notmuch_config_list_move_to_next (list)) {
+      printf("%s %d\n", notmuch_config_list_key (list), NULL == notmuch_config_list_value(list));
+   }
+   notmuch_config_list_destroy (list);
+}
+EOF
+cat <<'EOF' >EXPECTED
+== stdout ==
+aaabefore 1
+testkey1 1
+testkey2 1
+zzzafter 1
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
 test_begin_subtest "notmuch_database_get_config_list: one prefix"
 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
 {
-- 
2.27.0
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: