2 test_description="notmuch_database_* 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>
15 int main (int argc, char** argv)
17 notmuch_database_t *db;
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 : "");
30 const char *stat_str = notmuch_database_status_string (db);
32 fputs (stat_str, stderr);
38 test_begin_subtest "get status_string with closed db"
39 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
42 EXPECT0(notmuch_database_close (db));
43 str = notmuch_database_status_string (db);
44 printf("%d\n", str == NULL);
52 test_expect_equal_file EXPECTED OUTPUT
54 test_begin_subtest "get path with closed db"
55 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
58 EXPECT0(notmuch_database_close (db));
59 path = notmuch_database_get_path (db);
68 test_expect_equal_file EXPECTED OUTPUT
70 test_begin_subtest "get version with closed db"
71 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
74 EXPECT0(notmuch_database_close (db));
75 version = notmuch_database_get_version (db);
76 printf ("%u\n", version);
77 stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
84 A Xapian exception occurred at lib/database.cc:XXX: Database has been closed
86 test_expect_equal_file EXPECTED OUTPUT