]> git.notmuchmail.org Git - notmuch/commitdiff
test: regression test for n_directory_{get,set}_mtime
authorDavid Bremner <david@tethera.net>
Sat, 1 Aug 2020 12:26:00 +0000 (09:26 -0300)
committerDavid Bremner <david@tethera.net>
Tue, 4 Aug 2020 00:00:25 +0000 (21:00 -0300)
The mtime is cached, so closing the db is not a problem. Writing the
mtime throws an exception, which is caught.

test/T563-lib-directory.sh

index 7e44e80561ca0200730ef4a7723ec641057bebaa..28325ff23605cae0ea644d13c69b2fc0b2bb4896 100755 (executable)
@@ -109,4 +109,22 @@ 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.
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+restore_database
+
 test_done