]> git.notmuchmail.org Git - notmuch/commitdiff
test: add regression test for notmuch_message_has_maildir_flag
authorDavid Bremner <david@tethera.net>
Thu, 9 Jul 2020 00:17:00 +0000 (21:17 -0300)
committerDavid Bremner <david@tethera.net>
Mon, 20 Jul 2020 11:45:15 +0000 (08:45 -0300)
This passes the NULL return inside _ensure_maildir_flags does not
break anything. Probably this should be handled more explicitely.

lib/message.cc
test/T560-lib-error.sh

index 4e1be986abc326842314b9d92c8553bb1aea016d..bb4b2fa12a00ef6a8e99c9e0ba73a181e842a7cd 100644 (file)
@@ -1732,7 +1732,8 @@ _ensure_maildir_flags (notmuch_message_t *message, bool force)
            message->maildir_flags = NULL;
        }
     }
-
+    /* n_m_get_filenames returns NULL for errors, which terminates the
+     * loop */
     for (filenames = notmuch_message_get_filenames (message);
         notmuch_filenames_valid (filenames);
         notmuch_filenames_move_to_next (filenames)) {
index 36c4c1cec9c81368d945f09af35b854a2e8a2ba1..02478e92113045ec5407d91972eeb08b79160203 100755 (executable)
@@ -533,4 +533,20 @@ cat <<EOF > EXPECTED
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "Handle read maildir flag with closed database"
+cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
+    {
+        notmuch_bool_t is_set = -1;
+        is_set = notmuch_message_has_maildir_flag (message, 'S');
+        printf("%d\n%d\n", message != NULL, is_set == FALSE || is_set == TRUE);
+    }
+EOF
+cat <<EOF > EXPECTED
+== stdout ==
+1
+1
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
 test_done