test: add known broken test for error handling on closed database
authorDavid Bremner <david@tethera.net>
Tue, 30 Jun 2020 01:14:08 +0000 (22:14 -0300)
committerDavid Bremner <david@tethera.net>
Sat, 4 Jul 2020 00:01:39 +0000 (21:01 -0300)
Based on id:87d05je1j6.fsf@powell.devork.be

test/T560-lib-error.sh
test/notmuch-test.h

index 06a6b860ae8a09f5362a18a3a36acf4a734c1ed4..7284a92b6648c8301fe54418c6b8db37f75092e4 100755 (executable)
@@ -318,4 +318,45 @@ EOF
 test_expect_equal_file EXPECTED OUTPUT.clean
 restore_database
 
+cat <<EOF > c_head2
+#include <stdio.h>
+#include <notmuch.h>
+#include <notmuch-test.h>
+#include <assert.h>
+int main (int argc, char** argv)
+{
+   notmuch_database_t *db;
+   notmuch_status_t stat;
+   char *msg = NULL;
+   notmuch_message_t *message = NULL;
+   const char *id = "1258471718-6781-1-git-send-email-dottedmag@dottedmag.net";
+
+   stat = notmuch_database_open_verbose (argv[1], NOTMUCH_DATABASE_MODE_READ_WRITE, &db, &msg);
+   if (stat != NOTMUCH_STATUS_SUCCESS) {
+     fprintf (stderr, "error opening database: %d %s\n", stat, msg ? msg : "");
+     exit (1);
+   }
+   EXPECT0(notmuch_database_find_message (db, id, &message));
+   assert(message != NULL);
+   EXPECT0(notmuch_database_close (db));
+EOF
+
+backup_database
+test_begin_subtest "Handle getting message-id from closed database"
+test_subtest_known_broken
+cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
+    {
+        const char *id2;
+        id2=notmuch_message_get_message_id (message);
+        printf("%s\n%d\n", id, id2==NULL);
+    }
+EOF
+cat <<EOF > EXPECTED
+== stdout ==
+1258471718-6781-1-git-send-email-dottedmag@dottedmag.net
+1
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
 test_done
index df852da9de552fd35dd7305018d001763e6aa7c3..34dbb8e0403feefc4be402178943d8576a8d9c01 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef _NOTMUCH_TEST_H
 #define _NOTMUCH_TEST_H
 #include <stdio.h>
+#include <stdlib.h>
 #include <notmuch.h>
 
 inline static void