]> git.notmuchmail.org Git - notmuch/blobdiff - test/T568-lib-thread.sh
lib/database: delete stemmer on destroy
[notmuch] / test / T568-lib-thread.sh
index 66066854eb832cfb3f7183a413c134fb0ea13516..b45836cdd989ca6ac25bc58bc15f7a13fa38dd63 100755 (executable)
@@ -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 <<EOF > c_head
-#include <stdio.h>
-#include <notmuch.h>
 #include <notmuch-test.h>
+
 int main (int argc, char** argv)
 {
    notmuch_database_t *db;
@@ -30,7 +34,7 @@ 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);
    if (stat != NOTMUCH_STATUS_SUCCESS) {
@@ -52,10 +56,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 <<EOF > EXPECTED
 == stdout ==
 1
-0000000000000009
+${thread_num}
 == stderr ==
 EOF
 test_expect_equal_file EXPECTED OUTPUT
@@ -285,6 +290,37 @@ unread
 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 <<EOF > 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}
     {