test: regression test for traversing config list with closed db

Also mention error return in API docs
This commit is contained in:
David Bremner 2020-08-01 09:26:02 -03:00
parent a0b2a54aa7
commit e3f88436b7
2 changed files with 23 additions and 0 deletions

View file

@ -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);

View file

@ -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}
{