]> git.notmuchmail.org Git - notmuch/blob - test/T570-revision-tracking.sh
lib: API to retrieve database revision and UUID
[notmuch] / test / T570-revision-tracking.sh
1 #!/usr/bin/env bash
2 test_description="database revision tracking"
3
4 . ./test-lib.sh || exit 1
5
6 add_email_corpus
7
8 test_begin_subtest "notmuch_database_get_revision"
9 test_C ${MAIL_DIR} <<'EOF'
10 #include <stdio.h>
11 #include <string.h>
12 #include <notmuch.h>
13 int main (int argc, char** argv)
14 {
15    notmuch_database_t *db;
16    notmuch_status_t stat;
17    unsigned long revision;
18    const char *uuid;
19
20    unsigned long rev;
21
22    stat = notmuch_database_open (argv[1], NOTMUCH_DATABASE_MODE_READ_ONLY, &db);
23    if (stat)
24        fputs ("open failed\n", stderr);
25    revision = notmuch_database_get_revision (db, &uuid);
26    printf("%s\t%lu\n", uuid, revision);
27 }
28 EOF
29 notmuch_uuid_sanitize < OUTPUT > CLEAN
30 cat <<'EOF' >EXPECTED
31 == stdout ==
32 UUID    53
33 == stderr ==
34 EOF
35 test_expect_equal_file EXPECTED CLEAN
36
37 test_done