aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2015-06-10 07:58:44 +0200
committerDavid Bremner <david@tethera.net>2015-06-12 07:34:47 +0200
commitb59ad1a9cc6ea03764b1cd3d038920581ac5a9c4 (patch)
treedbd75a59ebd84685fdb67c14c116ff29e2862531 /test
parenta5a21bbe78725db70153b6bf59c1856de2dcae4d (diff)
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.
Diffstat (limited to 'test')
-rwxr-xr-xtest/T070-insert.sh2
-rwxr-xr-xtest/T560-lib-error.sh42
2 files changed, 41 insertions, 3 deletions
diff --git a/test/T070-insert.sh b/test/T070-insert.sh
index 74f19552..7e71c3b1 100755
--- a/test/T070-insert.sh
+++ b/test/T070-insert.sh
@@ -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
diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh
index c99b17ed..9f5f7aef 100755
--- a/test/T560-lib-error.sh
+++ b/test/T560-lib-error.sh
@@ -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