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"
14 #include <notmuch-test.h>
16 int main (int argc, char** argv)
18 notmuch_database_t *db;
19 notmuch_directory_t *dir;
20 notmuch_status_t stat = NOTMUCH_STATUS_SUCCESS;
23 stat = notmuch_database_open_verbose (argv[1], NOTMUCH_DATABASE_MODE_READ_WRITE, &db, &msg);
24 if (stat != NOTMUCH_STATUS_SUCCESS) {
25 fprintf (stderr, "error opening database: %d %s\n", stat, msg ? msg : "");
29 EXPECT0(notmuch_database_get_directory (db, "bar", &dir));
30 EXPECT0(notmuch_database_close (db));
35 const char *stat_str = notmuch_database_status_string (db);
37 fputs (stat_str, stderr);
43 test_begin_subtest "get child directories for a closed db"
44 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
46 notmuch_filenames_t *children;
47 children = notmuch_directory_get_child_directories (dir);
48 printf ("%d\n", children == NULL);
49 stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
56 A Xapian exception occurred at lib/directory.cc:XXX: Database has been closed
58 test_expect_equal_file EXPECTED OUTPUT
60 test_begin_subtest "get child filenames for a closed db"
61 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
63 notmuch_filenames_t *children;
64 children = notmuch_directory_get_child_files (dir);
65 printf ("%d\n", children == NULL);
66 stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
73 A Xapian exception occurred at lib/directory.cc:XXX: Database has been closed
75 test_expect_equal_file EXPECTED OUTPUT
78 test_begin_subtest "delete directory document for a closed db"
79 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
81 stat = notmuch_directory_delete (dir);
82 printf ("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
89 A Xapian exception occurred deleting directory entry: Database has been closed.
91 test_expect_equal_file EXPECTED OUTPUT
95 test_begin_subtest "get/set mtime of directory for a closed db"
96 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
98 time_t stamp = notmuch_directory_get_mtime (dir);
99 stat = notmuch_directory_set_mtime (dir, stamp);
100 printf ("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
107 A Xapian exception occurred setting directory mtime: Database has been closed.
109 test_expect_equal_file EXPECTED OUTPUT
113 test_begin_subtest "get/set mtime of directory for a closed db"
114 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
116 time_t stamp = notmuch_directory_get_mtime (dir);
117 stat = notmuch_directory_set_mtime (dir, stamp);
118 printf ("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
125 A Xapian exception occurred setting directory mtime: Database has been closed.
127 test_expect_equal_file EXPECTED OUTPUT