David Bremner
1d5d0ae686
lib/message: move xapian call inside try/catch block in _n_m_delete
...
The call to delete_document can throw exceptions (and can happen in
practice [1]), so catch the exception and extract the error
message. As a side effect, also move the call to _n_m_has_term inside
the try/catch. This should not change anything as that function
already traps any Xapian exceptions.
[1]: id:wwuk039sk2p.fsf@chaotikum.eu
2022-12-27 11:59:46 -04:00
David Bremner
966f40086f
test: add known broken test for exception handling in _n_m_delete
...
In [1], Thomas Schneider reported an uncaught Xapian exception when
running out of disk space. We generate the same exception via database
corruption.
[1]: id:wwuk039sk2p.fsf@chaotikum.eu
2022-12-27 11:59:38 -04:00
David Bremner
6f749dd24a
lib: check for writable db in n_m_tags_maildir_flags
...
The database needs to be writable because the list of stored file
names will change in general.
2022-06-25 16:06:34 -03:00
David Bremner
3f27cce71f
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.
2022-06-25 16:06:18 -03:00
David Bremner
8ade833ec2
test: error handling for n_m_tags_to_maildir_flags
...
The closed database case should fail gracefully, but currently it
segfaults.
2022-06-25 16:05:16 -03:00
David Bremner
9e9d0e5ffc
test: error handling in _n_message_{add,remove}_filename
...
Use a closed database to force throwing a Xapian exception. Leave the
check vague to accomodate a potential explicit check for open database.
2022-06-25 12:55:02 -03:00
David Bremner
a581755fbb
test: _notmuch_message_remove_term catches exceptions.
...
Unfortunately we can't differentiate between the two distinct error
conditions for Document::remove_term.
2022-06-25 12:55:02 -03:00
David Bremner
f48d2e2ff8
lib/message: catch exceptions in _n_m_add_term
...
Some code movement is needed to make sure the cache is only
invalidated when the Xapian operation succeeds.
2022-06-25 12:55:02 -03:00
David Bremner
f6e7a9dde5
test: replace deprecated use of notmuch_database_open_verbose
...
We need to do it some day, and it is a bit annoying to read
deprecation messages in broken tests.
2022-05-29 07:36:32 -03:00
David Bremner
1643c0459a
test: move system includes to notmuch-test.h
...
This removes some redudant includes, and will also make it easier to
introduce "#define _GNU_SOURCE", which must come before all system
includes.
2021-12-04 12:36:08 -04:00
David Bremner
97fadd0645
test: clean up some extra whitespace.
...
The extra space is mainly just untidy.
2021-03-12 07:19:14 -04:00
David Bremner
c151506773
test: regression test for n_m_get_filenames
...
Closing the database after the iterator is created is not a problem.
2020-08-03 20:50:15 -03:00
David Bremner
2b6e73d895
test: split header for lib-message tests.
...
This allows finer control over when to close the database.
2020-08-03 20:48:51 -03:00
David Bremner
6ccc4338a4
test: add regression tests for n_thread_get_toplevel_messages
...
Include a test for the previously omitted non-trivial code path for
notmuch_thread_get_replies.
2020-07-31 07:41:00 -03:00
David Bremner
85da95e266
test: move notmuch_message_* tests to their own file
...
This is for consistency with the recently added tests for
notmuch_database_*.
2020-07-29 12:18:11 -03:00