aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2015-04-06 07:39:55 +0900
committerDavid Bremner <david@tethera.net>2015-08-14 18:23:49 +0200
commitf76d8f82dd004cf14426a91e8a80dcd2a4b97317 (patch)
treeb2a08fb89242d809d095665a84ff75c6d7d142e3 /test
parent5a3b42fb8c556397841b86c5fda1c4554dab253a (diff)
cli: add global option "--uuid"
The function notmuch_exit_if_unmatched_db_uuid is split from notmuch_process_shared_options because it needs an open notmuch database. There are two exceptional cases in uuid handling. 1) notmuch config and notmuch setup don't currently open the database, so it doesn't make sense to check the UUID. 2) notmuch compact opens the database inside the library, so we either need to open the database just to check uuid, or change the API.
Diffstat (limited to 'test')
-rwxr-xr-xtest/T570-revision-tracking.sh27
-rw-r--r--test/random-corpus.c2
2 files changed, 29 insertions, 0 deletions
diff --git a/test/T570-revision-tracking.sh b/test/T570-revision-tracking.sh
index 4fff6896..20b44cbe 100755
--- a/test/T570-revision-tracking.sh
+++ b/test/T570-revision-tracking.sh
@@ -46,4 +46,31 @@ notmuch tag +a-random-tag-8743632 '*'
after=$(notmuch count --lastmod '*' | cut -f3)
result=$(($before < $after))
test_expect_equal 1 ${result}
+
+notmuch count --lastmod '*' | cut -f2 > UUID
+
+test_expect_success 'search succeeds with correct uuid' \
+ "notmuch search --uuid=$(cat UUID) '*'"
+
+test_expect_success 'uuid works as global option ' \
+ "notmuch --uuid=$(cat UUID) search '*'"
+
+test_expect_code 1 'uuid works as global option II' \
+ "notmuch --uuid=this-is-no-uuid search '*'"
+
+test_expect_code 1 'search fails with incorrect uuid' \
+ "notmuch search --uuid=this-is-no-uuid '*'"
+
+test_expect_success 'show succeeds with correct uuid' \
+ "notmuch show --uuid=$(cat UUID) '*'"
+
+test_expect_code 1 'show fails with incorrect uuid' \
+ "notmuch show --uuid=this-is-no-uuid '*'"
+
+test_expect_success 'tag succeeds with correct uuid' \
+ "notmuch tag --uuid=$(cat UUID) +test '*'"
+
+test_expect_code 1 'tag fails with incorrect uuid' \
+ "notmuch tag --uuid=this-is-no-uuid '*' +test2"
+
test_done
diff --git a/test/random-corpus.c b/test/random-corpus.c
index b377eb40..d74271d9 100644
--- a/test/random-corpus.c
+++ b/test/random-corpus.c
@@ -119,6 +119,8 @@ const notmuch_opt_desc_t notmuch_shared_options[] = {
{ 0, 0, 0, 0, 0 }
};
+char *notmuch_requested_db_uuid = NULL;
+
void
notmuch_process_shared_options (unused (const char *dummy))
{