2 test_description="API tests for tags"
4 . $(dirname "$0")/test-lib.sh || exit 1
8 test_begin_subtest "building database"
9 test_expect_success "NOTMUCH_NEW"
13 #include <sys/types.h>
19 int main (int argc, char** argv)
21 notmuch_database_t *db;
22 notmuch_status_t stat;
27 stat = notmuch_database_open_with_config (argv[1],
28 NOTMUCH_DATABASE_MODE_READ_WRITE,
29 NULL, NULL, &db, &msg);
30 if (stat != NOTMUCH_STATUS_SUCCESS) {
31 fprintf (stderr, "error opening database\n%s\n%s\n", notmuch_status_to_string (stat), msg ? msg : "");
37 const char *stat_str = notmuch_database_status_string (db);
39 fputs (stat_str, stderr);
45 POSTLIST_PATH=(${MAIL_DIR}/.notmuch/xapian/postlist.*)
48 test_begin_subtest "Xapian exception getting tags"
49 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${POSTLIST_PATH}
51 notmuch_tags_t *tags = NULL;
52 fd = open(argv[2],O_WRONLY|O_TRUNC);
54 fprintf (stderr, "error opening %s\n", argv[1]);
57 tags = notmuch_database_get_all_tags (db);
58 stat = (tags == NULL);
61 sed 's/^\(A Xapian exception [^:]*\):.*$/\1/' < OUTPUT > OUTPUT.clean
65 A Xapian exception occurred getting tags
67 test_expect_equal_file EXPECTED OUTPUT.clean
70 test_begin_subtest "NULL tags are not valid"
71 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
73 notmuch_bool_t valid = TRUE;
74 valid = notmuch_tags_valid (NULL);
75 fprintf(stdout, "valid = %d\n", valid);
83 test_expect_equal_file EXPECTED OUTPUT