diff options
| author | David Bremner <david@tethera.net> | 2022-05-25 07:51:16 -0300 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2022-06-25 16:06:18 -0300 |
| commit | 3f27cce71f9f154cb0c2134c32d41c31eb62a239 (patch) | |
| tree | 885c88706efdd7a771944287e4c2c27cfe737e11 /test | |
| parent | 7e654e2a456c552052e9e50b83da73b4d31d8f2b (diff) | |
lib: add NOTMUCH_STATUS_CLOSED_DATABASE, use in _n_d_ensure_writable
In order for a database to actually be writeable, it must be the case that it
is open, not just the correct type of Xapian object. By explicitely
checking, we are able to provide better error reporting, in particular
for the previously broken test in T566-lib-message.
Diffstat (limited to 'test')
| -rwxr-xr-x | test/T562-lib-database.sh | 8 | ||||
| -rwxr-xr-x | test/T563-lib-directory.sh | 26 | ||||
| -rwxr-xr-x | test/T566-lib-message.sh | 10 |
3 files changed, 13 insertions, 31 deletions
diff --git a/test/T562-lib-database.sh b/test/T562-lib-database.sh index 64233c37..fedfc9ed 100755 --- a/test/T562-lib-database.sh +++ b/test/T562-lib-database.sh @@ -243,14 +243,14 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} const char *path = talloc_asprintf(db, "%s/01:2,", argv[1]); EXPECT0(notmuch_database_close (db)); stat = notmuch_database_index_file (db, path, NULL, &msg); - printf ("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION); + printf ("%d\n", stat == NOTMUCH_STATUS_CLOSED_DATABASE); } EOF cat <<EOF > EXPECTED == stdout == 1 == stderr == -A Xapian exception occurred finding message: Database has been closed. +Cannot write to a closed database. EOF test_expect_equal_file EXPECTED OUTPUT @@ -358,14 +358,14 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} { EXPECT0(notmuch_database_close (db)); stat = notmuch_database_set_config (db, "foo", "bar"); - printf("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION); + printf("%d\n", stat == NOTMUCH_STATUS_CLOSED_DATABASE); } EOF cat <<EOF > EXPECTED == stdout == 1 == stderr == -Error: A Xapian exception occurred setting metadata: Database has been closed +Cannot write to a closed database. EOF test_expect_equal_file EXPECTED OUTPUT diff --git a/test/T563-lib-directory.sh b/test/T563-lib-directory.sh index 22b9e0b9..4711fcdf 100755 --- a/test/T563-lib-directory.sh +++ b/test/T563-lib-directory.sh @@ -79,14 +79,14 @@ test_begin_subtest "delete directory document for a closed db" cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} { stat = notmuch_directory_delete (dir); - printf ("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION); + printf ("%d\n", stat == NOTMUCH_STATUS_CLOSED_DATABASE); } EOF cat <<EOF > EXPECTED == stdout == 1 == stderr == -A Xapian exception occurred deleting directory entry: Database has been closed. +Cannot write to a closed database. EOF test_expect_equal_file EXPECTED OUTPUT restore_database @@ -97,32 +97,14 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} { time_t stamp = notmuch_directory_get_mtime (dir); stat = notmuch_directory_set_mtime (dir, stamp); - printf ("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION); + printf ("%d\n", stat == NOTMUCH_STATUS_CLOSED_DATABASE); } EOF cat <<EOF > EXPECTED == stdout == 1 == stderr == -A Xapian exception occurred setting directory mtime: Database has been closed. -EOF -test_expect_equal_file EXPECTED OUTPUT -restore_database - -backup_database -test_begin_subtest "get/set mtime of directory for a closed db" -cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} - { - time_t stamp = notmuch_directory_get_mtime (dir); - stat = notmuch_directory_set_mtime (dir, stamp); - printf ("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION); - } -EOF -cat <<EOF > EXPECTED -== stdout == -1 -== stderr == -A Xapian exception occurred setting directory mtime: Database has been closed. +Cannot write to a closed database. EOF test_expect_equal_file EXPECTED OUTPUT restore_database diff --git a/test/T566-lib-message.sh b/test/T566-lib-message.sh index a98224c9..87e70441 100755 --- a/test/T566-lib-message.sh +++ b/test/T566-lib-message.sh @@ -231,7 +231,7 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} { notmuch_status_t status; status = notmuch_message_add_tag (message, "boom"); - printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_XAPIAN_EXCEPTION); + printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_CLOSED_DATABASE); } EOF cat <<EOF > EXPECTED @@ -247,7 +247,7 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} { notmuch_status_t status; status = notmuch_message_remove_tag (message, "boom"); - printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_XAPIAN_EXCEPTION); + printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_CLOSED_DATABASE); } EOF cat <<EOF > EXPECTED @@ -427,7 +427,7 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} { notmuch_status_t status; status = notmuch_message_remove_all_tags (message); - printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_XAPIAN_EXCEPTION); + printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_CLOSED_DATABASE); } EOF cat <<EOF > EXPECTED @@ -443,7 +443,7 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} { notmuch_status_t status; status = notmuch_message_freeze (message); - printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_SUCCESS); + printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_CLOSED_DATABASE); } EOF cat <<EOF > EXPECTED @@ -459,7 +459,7 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} { notmuch_status_t status; status = notmuch_message_thaw (message); - printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW); + printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_CLOSED_DATABASE); } EOF cat <<EOF > EXPECTED |
