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
e5f3c3ed50
lib: add stub for notmuch_database_open_with_config
...
Initially document the intended API and copy the code from
notmuch_database_open_verbose. Most of the documented functionality is
not there yet.
2021-02-06 18:57:35 -04:00
David Bremner
4743e87c2c
lib: cache configuration information from database
...
The main goal is to allow configuration information to be temporarily
overridden by a separate config file. That will require further
changes not in this commit.
The performance impact is unclear, and will depend on the balance
between number of queries and number of distinct metadata items read
on the first call to n_d_get_config.
2021-02-06 18:56:05 -04:00
David Bremner
fe449f779d
test: fix uninitialized variable use in T562-lib-database
...
Fix a copy paste error of using the boolean ret as a notmuch_status_t,
and uninitialized.
2020-08-16 14:04:36 -03:00
David Bremner
0e4695abaa
test: regression tests for n_indexopts_{get,set}_decrypt_policy
...
The main criteria is that they don't crash. Working with a closed
database is a bonus.
2020-08-03 21:05:29 -03:00
David Bremner
31dab9b1cd
lib: return NULL from n_d_get_default_indexopts on error
...
This is a rare and probably serious programming error, so better not
to silently return a default value.
2020-08-03 20:45:58 -03:00
David Bremner
24cf4381b8
test: add known broken test for n_d_get_default_indexopts
...
Xapian exceptions are swallowed and turned into default return value.
2020-07-22 19:52:55 -03:00
David Bremner
b268c8c071
lib: fix error return bug with n_d_set_config.
...
The catch block either needs to return, or the function needs to
return "status". Choose the latter for consistency with
n_d_get_config.
2020-07-22 19:52:55 -03:00
David Bremner
f6d74be840
test: add known broken test for n_d_set_config
...
Error status is currently lost.
2020-07-22 19:52:55 -03:00
David Bremner
a5e13d5218
test: add regression test for n_d_get_config
...
Xapian exceptions seem to handled OK, at least for this case.
2020-07-22 19:52:55 -03:00
David Bremner
dfab190a40
lib: add regresion test for n_d_get_all_tags
...
Existing error handling seems adequate, if not ideal.
2020-07-22 19:52:55 -03:00
David Bremner
64aa896151
lib: add regression test for n_d_find_message_by_filename
...
At least this Xapian exception is caught. Make sure it stays that way.
2020-07-22 19:52:55 -03:00
David Bremner
ce360ce4c9
lib: rename _n_d_create to _n_d_find_or_create
...
The error message and name were confusing when called in some "read
only" context.
2020-07-22 19:52:55 -03:00
David Bremner
97c887282a
test: add known broken test for notmuch_database_remove_message
...
The current error message is a bit confusing; fix in next commit.
2020-07-22 19:52:55 -03:00
David Bremner
c477d7ce31
lib: convert relative filenames to absolute in n_d_index_file
...
The API docs promise to handle relative filenames, but the code did
not do it.
Also check for files outside the mail root, as implied by the API
description.
This fixes the bug reported at
id:87sgdqo0rz.fsf@tethera.net
2020-07-22 19:52:55 -03:00
David Bremner
be3f4aec3f
test: add known broken test for indexing relative path
...
The current code seems to look for the path relative to the current
working directory, rather than the mail store root.
2020-07-22 19:52:55 -03:00
David Bremner
9ab3e2e77d
test: regression test for n_d_index_file closed db
...
Current exception handling seems OK, at least for this case.
2020-07-22 19:52:55 -03:00
David Bremner
1ca805a962
test: add regression test for n_d_get_directory
...
At least this exception is already handled correctly.
2020-07-22 19:52:55 -03:00
David Bremner
959cb4b7a7
test: regression test for n_d_get_revision
...
This function only accesses data cached by notmuch, so being closed is
not a problem.
2020-07-22 19:52:55 -03:00
David Bremner
bcb02dd8fc
test: add regression test for n_d_{begin,end}_atomic
...
Xapian currently succeeds to begin/end a transaction on a closed database,
or at least does not throw an exception. Make the test robust against
this changing.
2020-07-22 19:52:55 -03:00
David Bremner
3f121d636e
test: regression test for n_d_upgrade
...
The logic is that if it's acceptable to return SUCCESS for read only
database, it's acceptable for a closed one.
2020-07-22 19:52:55 -03:00
David Bremner
f25fc8e211
lib/n_d_needs_upgrade: handle error return from n_d_get_version
...
Also clarify documentation of error return from n_d_needs_upgrade.
2020-07-22 19:52:55 -03:00
David Bremner
cf90431cbf
test: add known broken test for n_d_needs_upgrade
...
It's a bit arbitrary which value to return for errors, but the same
argument as for read only databases applies for errors.
2020-07-22 19:52:55 -03:00
David Bremner
37dc6045e4
test: add regression tests for notmuch database destroy
...
Either an open or closed database should be ok to destroy
2020-07-22 19:52:55 -03:00
David Bremner
964e783fd4
test: regression test for closing a closed database
...
This does not currently throw an error, and it should stay that way.
2020-07-22 19:52:55 -03:00
David Bremner
ab45654192
lib/n_d_get_version: catch exceptions and clarify the API
...
notmuch_database_get_version previously returned 0 on some errors, but
did not document this. Luckily 0 is not a valid database version.
2020-07-22 19:52:55 -03:00
David Bremner
920dc56e60
test: add known broken test for n_d_get_version on closed db
...
This should not crash, but it does currently.
2020-07-22 19:52:55 -03:00
David Bremner
f3a56b5f6d
test: regression tests for n_d_status_string and n_d_get_path
...
These do not crash on a closed database, and we want to keep it that
way.
Start a new file of tests as T560-lib-error was starting to get unwieldy.
2020-07-22 19:52:55 -03:00