diff options
| author | Austin Clements <aclements@csail.mit.edu> | 2014-10-13 02:20:02 -0400 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2015-08-13 23:52:51 +0200 |
| commit | 98ee460eaa98f1428aecf03dd39fcf314e6f62c0 (patch) | |
| tree | 60fc701a61c88ea92bd009f0f662c8107360f56b /test | |
| parent | 7f57b747b95eece465d10fd0acba20cc3dd868f1 (diff) | |
lib: API to retrieve database revision and UUID
This exposes the committed database revision to library users along
with a UUID that can be used to detect when revision numbers are no
longer comparable (e.g., because the database has been replaced).
Diffstat (limited to 'test')
| -rwxr-xr-x | test/T570-revision-tracking.sh | 37 | ||||
| -rw-r--r-- | test/test-lib.sh | 5 |
2 files changed, 42 insertions, 0 deletions
diff --git a/test/T570-revision-tracking.sh b/test/T570-revision-tracking.sh new file mode 100755 index 00000000..e0a57030 --- /dev/null +++ b/test/T570-revision-tracking.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +test_description="database revision tracking" + +. ./test-lib.sh || exit 1 + +add_email_corpus + +test_begin_subtest "notmuch_database_get_revision" +test_C ${MAIL_DIR} <<'EOF' +#include <stdio.h> +#include <string.h> +#include <notmuch.h> +int main (int argc, char** argv) +{ + notmuch_database_t *db; + notmuch_status_t stat; + unsigned long revision; + const char *uuid; + + unsigned long rev; + + stat = notmuch_database_open (argv[1], NOTMUCH_DATABASE_MODE_READ_ONLY, &db); + if (stat) + fputs ("open failed\n", stderr); + revision = notmuch_database_get_revision (db, &uuid); + printf("%s\t%lu\n", uuid, revision); +} +EOF +notmuch_uuid_sanitize < OUTPUT > CLEAN +cat <<'EOF' >EXPECTED +== stdout == +UUID 53 +== stderr == +EOF +test_expect_equal_file EXPECTED CLEAN + +test_done diff --git a/test/test-lib.sh b/test/test-lib.sh index 0bf7163e..126911fb 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -720,6 +720,11 @@ notmuch_date_sanitize () sed \ -e 's/^Date: Fri, 05 Jan 2001 .*0000/Date: GENERATED_DATE/' } + +notmuch_uuid_sanitize () +{ + sed 's/[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}/UUID/g' +} # End of notmuch helper functions # Use test_set_prereq to tell that a particular prerequisite is available. |
