X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=test%2FT560-lib-error.sh;h=c043e35eed55f3cf84ed7aea6a8037b7b6b4961f;hp=5a5f66b8c193073d26a739b2a13691da6dc3af52;hb=6eaadb43adae2cca2f8023830d498ef3164f7fe9;hpb=87d462a20423a25eaf4b54a90bfd538dd93da675 diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index 5a5f66b8..c043e35e 100755 --- a/test/T560-lib-error.sh +++ b/test/T560-lib-error.sh @@ -322,7 +322,6 @@ cat < c_head2 #include #include #include -#include int main (int argc, char** argv) { notmuch_database_t *db; @@ -337,17 +336,47 @@ int main (int argc, char** argv) exit (1); } EXPECT0(notmuch_database_find_message (db, id, &message)); - assert(message != NULL); EXPECT0(notmuch_database_close (db)); EOF -backup_database test_begin_subtest "Handle getting message-id from closed database" cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} { const char *id2; id2=notmuch_message_get_message_id (message); - printf("%s\n%d\n", id, id2==NULL); + printf("%d\n%d\n", message != NULL, id2==NULL); + } +EOF +cat < EXPECTED +== stdout == +1 +1 +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "Handle getting thread-id from closed database" +cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + const char *id2; + id2=notmuch_message_get_thread_id (message); + printf("%d\n%d\n", message != NULL, id2==NULL); + } +EOF +cat < EXPECTED +== stdout == +1 +1 +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "Handle getting header from closed database" +cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + const char *from; + from=notmuch_message_get_header (message, "from"); + printf("%s\n%d\n", id, from == NULL); } EOF cat < EXPECTED @@ -358,4 +387,88 @@ cat < EXPECTED 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_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + notmuch_messages_t *replies; + replies = notmuch_message_get_replies (message); + printf("%d\n%d\n", message != NULL, replies==NULL); + } +EOF +cat < EXPECTED +== stdout == +1 +1 +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "Handle getting message filename from closed database" +cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + const char *filename; + filename = notmuch_message_get_filename (message); + printf("%d\n%d\n", message != NULL, filename == NULL); + } +EOF +cat < EXPECTED +== stdout == +1 +1 +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "Handle getting all message filenames from closed database" +cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + notmuch_filenames_t *filenames; + filenames = notmuch_message_get_filenames (message); + printf("%d\n%d\n", message != NULL, filenames == NULL); + } +EOF +cat < EXPECTED +== stdout == +1 +1 +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "Handle getting ghost flag from closed database" +test_subtest_known_broken +cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + notmuch_bool_t result; + result = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_GHOST); + printf("%d\n%d\n", message != NULL, result == FALSE); + } +EOF +cat < EXPECTED +== stdout == +1 +1 +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "Handle getting date from closed database" +cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + time_t result; + result = notmuch_message_get_date (message); + printf("%d\n%d\n", message != NULL, result == 0); + } +EOF +cat < EXPECTED +== stdout == +1 +1 +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + + test_done