mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-22 02:48:08 +01:00
test: add known broken test for error handling on closed database
Based on id:87d05je1j6.fsf@powell.devork.be
This commit is contained in:
parent
552029f748
commit
2c17327ee5
2 changed files with 42 additions and 0 deletions
|
@ -318,4 +318,45 @@ EOF
|
||||||
test_expect_equal_file EXPECTED OUTPUT.clean
|
test_expect_equal_file EXPECTED OUTPUT.clean
|
||||||
restore_database
|
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
|
test_done
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef _NOTMUCH_TEST_H
|
#ifndef _NOTMUCH_TEST_H
|
||||||
#define _NOTMUCH_TEST_H
|
#define _NOTMUCH_TEST_H
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <notmuch.h>
|
#include <notmuch.h>
|
||||||
|
|
||||||
inline static void
|
inline static void
|
||||||
|
|
Loading…
Reference in a new issue