mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
lib: add NOTMUCH_STATUS_PATH_ERROR
The difference with FILE_ERROR is that this is for things that are wrong with the path before looking at the disk. Add some 3 tests; two broken as a reminder to actually use this new code.
This commit is contained in:
parent
a5a21bbe78
commit
b59ad1a9cc
4 changed files with 48 additions and 3 deletions
|
@ -342,6 +342,8 @@ notmuch_status_to_string (notmuch_status_t status)
|
|||
return "Unsupported operation";
|
||||
case NOTMUCH_STATUS_UPGRADE_REQUIRED:
|
||||
return "Operation requires a database upgrade";
|
||||
case NOTMUCH_STATUS_PATH_ERROR:
|
||||
return "Path supplied is illegal for this function";
|
||||
default:
|
||||
case NOTMUCH_STATUS_LAST_STATUS:
|
||||
return "Unknown error status value";
|
||||
|
|
|
@ -163,6 +163,11 @@ typedef enum _notmuch_status {
|
|||
* The operation requires a database upgrade.
|
||||
*/
|
||||
NOTMUCH_STATUS_UPGRADE_REQUIRED,
|
||||
/**
|
||||
* There is a problem with the proposed path, e.g. a relative path
|
||||
* passed to a function expecting an absolute path.
|
||||
*/
|
||||
NOTMUCH_STATUS_PATH_ERROR,
|
||||
/**
|
||||
* Not an actual status value. Just a way to find out how many
|
||||
* valid status values there are.
|
||||
|
|
|
@ -188,7 +188,7 @@ notmuch config set new.tags $OLDCONFIG
|
|||
# DUPLICATE_MESSAGE_ID is not tested here, because it should actually pass.
|
||||
|
||||
for code in OUT_OF_MEMORY XAPIAN_EXCEPTION FILE_NOT_EMAIL \
|
||||
READ_ONLY_DATABASE UPGRADE_REQUIRED; do
|
||||
READ_ONLY_DATABASE UPGRADE_REQUIRED PATH_ERROR; do
|
||||
gen_insert_msg
|
||||
cat <<EOF > index-file-$code.gdb
|
||||
set breakpoint pending on
|
||||
|
|
|
@ -35,7 +35,8 @@ Error: Cannot open a database for a NULL path.
|
|||
EOF
|
||||
test_expect_equal_file EXPECTED OUTPUT
|
||||
|
||||
test_begin_subtest "Open nonexistent database"
|
||||
test_begin_subtest "Open relative path"
|
||||
test_subtest_known_broken
|
||||
test_C <<'EOF'
|
||||
#include <stdio.h>
|
||||
#include <notmuch.h>
|
||||
|
@ -49,7 +50,44 @@ EOF
|
|||
cat <<'EOF' >EXPECTED
|
||||
== stdout ==
|
||||
== stderr ==
|
||||
Error opening database at ./nonexistent/foo/.notmuch: No such file or directory
|
||||
Error: Database path must be absolute.
|
||||
EOF
|
||||
test_expect_equal_file EXPECTED OUTPUT
|
||||
|
||||
test_begin_subtest "Create database in relative path"
|
||||
test_subtest_known_broken
|
||||
test_C <<'EOF'
|
||||
#include <stdio.h>
|
||||
#include <notmuch.h>
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
notmuch_database_t *db;
|
||||
notmuch_status_t stat;
|
||||
stat = notmuch_database_create ("./nonexistent/foo", &db);
|
||||
}
|
||||
EOF
|
||||
cat <<'EOF' >EXPECTED
|
||||
== stdout ==
|
||||
== stderr ==
|
||||
Error: Database path must be absolute.
|
||||
EOF
|
||||
test_expect_equal_file EXPECTED OUTPUT
|
||||
|
||||
test_begin_subtest "Open nonexistent database"
|
||||
test_C ${PWD}/nonexistent/foo <<'EOF'
|
||||
#include <stdio.h>
|
||||
#include <notmuch.h>
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
notmuch_database_t *db;
|
||||
notmuch_status_t stat;
|
||||
stat = notmuch_database_open (argv[1], 0, 0);
|
||||
}
|
||||
EOF
|
||||
cat <<'EOF' >EXPECTED
|
||||
== stdout ==
|
||||
== stderr ==
|
||||
Error opening database at CWD/nonexistent/foo/.notmuch: No such file or directory
|
||||
EOF
|
||||
test_expect_equal_file EXPECTED OUTPUT
|
||||
|
||||
|
|
Loading…
Reference in a new issue