X-Git-Url: https://git.cworth.org/git?p=notmuch;a=blobdiff_plain;f=test%2FT568-lib-thread.sh;h=b4c24ca23b049b4ec8e06a67d28e9d7fb1bae407;hp=5816cfbcbc9b6090bf6de6ad5ad0f4c2d33bce12;hb=2707c06a0fc587a68096a3ec6f054ba4f0d7e7c7;hpb=02ab473115f064c8f53fc46cc06a33e40588906d diff --git a/test/T568-lib-thread.sh b/test/T568-lib-thread.sh index 5816cfbc..b4c24ca2 100755 --- a/test/T568-lib-thread.sh +++ b/test/T568-lib-thread.sh @@ -8,6 +8,11 @@ add_email_corpus test_begin_subtest "building database" test_expect_success "NOTMUCH_NEW" +test_begin_subtest "finding thread" +THREAD=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu) +count=$(notmuch count $THREAD) +test_expect_equal "$count" "7" + cat <<'EOF' > c_tail if (stat) { const char *stat_str = notmuch_database_status_string (db); @@ -19,9 +24,8 @@ cat <<'EOF' > c_tail EOF cat < c_head -#include -#include #include + int main (int argc, char** argv) { notmuch_database_t *db; @@ -30,9 +34,11 @@ int main (int argc, char** argv) notmuch_thread_t *thread = NULL; notmuch_threads_t *threads = NULL; notmuch_query_t *query = NULL; - const char *id = "thread:0000000000000009"; + const char *id = "${THREAD}"; - stat = notmuch_database_open_verbose (argv[1], NOTMUCH_DATABASE_MODE_READ_WRITE, &db, &msg); + stat = notmuch_database_open_with_config (argv[1], + NOTMUCH_DATABASE_MODE_READ_WRITE, + NULL, NULL, &db, &msg); if (stat != NOTMUCH_STATUS_SUCCESS) { fprintf (stderr, "error opening database: %d %s\n", stat, msg ? msg : ""); exit (1); @@ -52,10 +58,11 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} printf("%d\n%s\n", thread != NULL, id2); } EOF +thread_num=${THREAD#thread:} cat < EXPECTED == stdout == 1 -0000000000000009 +${thread_num} == stderr == EOF test_expect_equal_file EXPECTED OUTPUT @@ -92,4 +99,243 @@ cat < EXPECTED EOF test_expect_equal_file EXPECTED OUTPUT +test_begin_subtest "get top level messages with closed database" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + notmuch_messages_t *messages; + messages = notmuch_thread_get_toplevel_messages (thread); + printf("%d\n%d\n", thread != NULL, messages != NULL); + } +EOF +cat < EXPECTED +== stdout == +1 +1 +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "iterate over level messages with closed database" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + notmuch_messages_t *messages; + for (messages = notmuch_thread_get_toplevel_messages (thread); + notmuch_messages_valid (messages); + notmuch_messages_move_to_next (messages)) { + notmuch_message_t *message = notmuch_messages_get (messages); + const char *mid = notmuch_message_get_message_id (message); + printf("%s\n", mid); + } + } +EOF +cat < EXPECTED +== stdout == +20091117190054.GU3165@dottiness.seas.harvard.edu +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "iterate over level messages with closed database" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + notmuch_messages_t *messages; + for (messages = notmuch_thread_get_toplevel_messages (thread); + notmuch_messages_valid (messages); + notmuch_messages_move_to_next (messages)) { + notmuch_message_t *message = notmuch_messages_get (messages); + const char *mid = notmuch_message_get_message_id (message); + printf("%s\n", mid); + } + } +EOF +cat < EXPECTED +== stdout == +20091117190054.GU3165@dottiness.seas.harvard.edu +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "iterate over replies with closed database" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + notmuch_messages_t *messages = notmuch_thread_get_toplevel_messages (thread); + notmuch_message_t *message = notmuch_messages_get (messages); + notmuch_messages_t *replies; + for (replies = notmuch_message_get_replies (message); + notmuch_messages_valid (replies); + notmuch_messages_move_to_next (replies)) { + notmuch_message_t *message = notmuch_messages_get (replies); + const char *mid = notmuch_message_get_message_id (message); + + printf("%s\n", mid); + } + } +EOF +cat < EXPECTED +== stdout == +87iqd9rn3l.fsf@vertex.dottedmag +87ocn0qh6d.fsf@yoom.home.cworth.org +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "iterate over all messages with closed database" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + notmuch_messages_t *messages; + for (messages = notmuch_thread_get_messages (thread); + notmuch_messages_valid (messages); + notmuch_messages_move_to_next (messages)) { + notmuch_message_t *message = notmuch_messages_get (messages); + const char *mid = notmuch_message_get_message_id (message); + printf("%s\n", mid); + } + } +EOF +cat < EXPECTED +== stdout == +20091117190054.GU3165@dottiness.seas.harvard.edu +87iqd9rn3l.fsf@vertex.dottedmag +20091117203301.GV3165@dottiness.seas.harvard.edu +87fx8can9z.fsf@vertex.dottedmag +yunaayketfm.fsf@aiko.keithp.com +20091118005040.GA25380@dottiness.seas.harvard.edu +87ocn0qh6d.fsf@yoom.home.cworth.org +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "get authors from closed database" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + const char *authors; + authors = notmuch_thread_get_authors (thread); + printf("%d\n%s\n", thread != NULL, authors); + } +EOF +cat < EXPECTED +== stdout == +1 +Lars Kellogg-Stedman, Mikhail Gusarov, Keith Packard, Carl Worth +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "get subject from closed database" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + const char *subject; + subject = notmuch_thread_get_subject (thread); + printf("%d\n%s\n", thread != NULL, subject); + } +EOF +cat < EXPECTED +== stdout == +1 +[notmuch] Working with Maildir storage? +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "oldest date from closed database" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + time_t stamp; + stamp = notmuch_thread_get_oldest_date (thread); + printf("%d\n%d\n", thread != NULL, stamp > 0); + } +EOF +cat < EXPECTED +== stdout == +1 +1 +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "newest date from closed database" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + time_t stamp; + stamp = notmuch_thread_get_newest_date (thread); + printf("%d\n%d\n", thread != NULL, stamp > 0); + } +EOF +cat < EXPECTED +== stdout == +1 +1 +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "iterate tags from closed database" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + notmuch_tags_t *tags; + const char *tag; + for (tags = notmuch_thread_get_tags (thread); + notmuch_tags_valid (tags); + notmuch_tags_move_to_next (tags)) + { + tag = notmuch_tags_get (tags); + printf ("%s\n", tag); + } + } +EOF +cat < EXPECTED +== stdout == +inbox +signed +unread +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "collect tags with closed database" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + notmuch_messages_t *messages = notmuch_thread_get_messages (thread); + + notmuch_tags_t *tags = notmuch_messages_collect_tags (messages); + + const char *tag; + for (tags = notmuch_thread_get_tags (thread); + notmuch_tags_valid (tags); + notmuch_tags_move_to_next (tags)) + { + tag = notmuch_tags_get (tags); + printf ("%s\n", tag); + } + notmuch_tags_destroy (tags); + notmuch_messages_destroy (messages); + + printf("SUCCESS\n"); + } +EOF +cat < EXPECTED +== stdout == +inbox +signed +unread +SUCCESS +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "destroy thread with closed database" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + time_t stamp; + notmuch_thread_destroy (thread); + printf("SUCCESS\n"); + } +EOF +cat < EXPECTED +== stdout == +SUCCESS +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + test_done