2 test_description="notmuch_directory_* API"
4 . $(dirname "$0")/test-lib.sh || exit 1
8 test_begin_subtest "building database"
9 test_expect_success "NOTMUCH_NEW"
12 #include <notmuch-test.h>
14 int main (int argc, char** argv)
16 notmuch_database_t *db;
17 notmuch_directory_t *dir;
18 notmuch_status_t stat = NOTMUCH_STATUS_SUCCESS;
21 stat = notmuch_database_open_verbose (argv[1], NOTMUCH_DATABASE_MODE_READ_WRITE, &db, &msg);
22 if (stat != NOTMUCH_STATUS_SUCCESS) {
23 fprintf (stderr, "error opening database: %d %s\n", stat, msg ? msg : "");
27 EXPECT0(notmuch_database_get_directory (db, "bar", &dir));
28 EXPECT0(notmuch_database_close (db));
33 const char *stat_str = notmuch_database_status_string (db);
35 fputs (stat_str, stderr);
41 test_begin_subtest "get child directories for a closed db"
42 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
44 notmuch_filenames_t *children;
45 children = notmuch_directory_get_child_directories (dir);
46 printf ("%d\n", children == NULL);
47 stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
54 A Xapian exception occurred at directory.cc:XXX: Database has been closed
56 test_expect_equal_file EXPECTED OUTPUT
58 test_begin_subtest "get child filenames for a closed db"
59 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
61 notmuch_filenames_t *children;
62 children = notmuch_directory_get_child_files (dir);
63 printf ("%d\n", children == NULL);
64 stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
71 A Xapian exception occurred at directory.cc:XXX: Database has been closed
73 test_expect_equal_file EXPECTED OUTPUT
76 test_begin_subtest "delete directory document for a closed db"
77 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
79 stat = notmuch_directory_delete (dir);
80 printf ("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
87 A Xapian exception occurred deleting directory entry: Database has been closed.
89 test_expect_equal_file EXPECTED OUTPUT
93 test_begin_subtest "get/set mtime of directory for a closed db"
94 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
96 time_t stamp = notmuch_directory_get_mtime (dir);
97 stat = notmuch_directory_set_mtime (dir, stamp);
98 printf ("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
105 A Xapian exception occurred setting directory mtime: Database has been closed.
107 test_expect_equal_file EXPECTED OUTPUT
111 test_begin_subtest "get/set mtime of directory for a closed db"
112 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
114 time_t stamp = notmuch_directory_get_mtime (dir);
115 stat = notmuch_directory_set_mtime (dir, stamp);
116 printf ("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
123 A Xapian exception occurred setting directory mtime: Database has been closed.
125 test_expect_equal_file EXPECTED OUTPUT