test: add known broken test for n_d_needs_upgrade
authorDavid Bremner <david@tethera.net>
Thu, 16 Jul 2020 22:22:05 +0000 (19:22 -0300)
committerDavid Bremner <david@tethera.net>
Wed, 22 Jul 2020 22:52:55 +0000 (19:52 -0300)
It's a bit arbitrary which value to return for errors, but the same
argument as for read only databases applies for errors.

test/T562-lib-database.sh

index 83499d4a474656634a86b04bd13e205034a78f62..d7f70415701b261a2e93c7fd420b9f7e68ad26a3 100755 (executable)
@@ -131,4 +131,24 @@ cat <<EOF > EXPECTED
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "check a closed db for upgrade"
+test_subtest_known_broken
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+    {
+        notmuch_bool_t ret;
+
+        EXPECT0(notmuch_database_close (db));
+        ret = notmuch_database_needs_upgrade (db);
+        printf ("%d\n", ret == FALSE);
+        stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+    }
+EOF
+cat <<EOF > EXPECTED
+== stdout ==
+1
+== stderr ==
+A Xapian exception occurred at lib/database.cc:XXX: Database has been closed
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
 test_done