2 test_description="database revision tracking"
4 . $(dirname "$0")/test-lib.sh || exit 1
8 test_begin_subtest "notmuch_database_get_revision"
9 test_C ${MAIL_DIR} <<'EOF'
13 int main (int argc, char** argv)
15 notmuch_database_t *db;
16 notmuch_status_t stat;
17 unsigned long revision;
22 stat = notmuch_database_open (argv[1], NOTMUCH_DATABASE_MODE_READ_ONLY, &db);
24 fputs ("open failed\n", stderr);
25 revision = notmuch_database_get_revision (db, &uuid);
26 printf("%s\t%lu\n", uuid, revision);
29 notmuch_uuid_sanitize < OUTPUT > CLEAN
35 test_expect_equal_file EXPECTED CLEAN
37 grep '^[0-9a-f]' OUTPUT > INITIAL_OUTPUT
39 test_begin_subtest "output of count matches test code"
40 notmuch count --lastmod '*' | cut -f2-3 > OUTPUT
41 test_expect_equal_file INITIAL_OUTPUT OUTPUT
43 test_begin_subtest "modification count increases"
44 before=$(notmuch count --lastmod '*' | cut -f3)
45 notmuch tag +a-random-tag-8743632 '*'
46 after=$(notmuch count --lastmod '*' | cut -f3)
47 result=$(($before < $after))
48 test_expect_equal 1 ${result}
50 notmuch count --lastmod '*' | cut -f2 > UUID
52 test_begin_subtest "search succeeds with correct uuid"
53 test_expect_success "notmuch search --uuid=$(cat UUID) '*'"
55 test_begin_subtest "uuid works as global option"
56 test_expect_success "notmuch --uuid=$(cat UUID) search '*'"
58 test_begin_subtest "uuid works as global option II"
59 test_expect_code 1 "notmuch --uuid=this-is-no-uuid search '*'"
61 test_begin_subtest "search fails with incorrect uuid"
62 test_expect_code 1 "notmuch search --uuid=this-is-no-uuid '*'"
64 test_begin_subtest "show succeeds with correct uuid"
65 test_expect_success "notmuch show --uuid=$(cat UUID) '*'"
67 test_begin_subtest "show fails with incorrect uuid"
68 test_expect_code 1 "notmuch show --uuid=this-is-no-uuid '*'"
70 test_begin_subtest "tag succeeds with correct uuid"
71 test_expect_success "notmuch tag --uuid=$(cat UUID) +test '*'"
73 test_begin_subtest "tag fails with incorrect uuid"
74 test_expect_code 1 "notmuch tag --uuid=this-is-no-uuid '*' +test2"
76 test_begin_subtest 'lastmod:0.. matches everything'
77 total=$(notmuch count '*')
78 modtotal=$(notmuch count lastmod:0..)
79 test_expect_equal "$total" "$modtotal"
81 test_begin_subtest 'lastmod:1000000.. matches nothing'
82 modtotal=$(notmuch count lastmod:1000000..)
83 test_expect_equal 0 "$modtotal"
85 test_begin_subtest 'exclude one message using lastmod'
86 lastmod=$(notmuch count --lastmod '*' | cut -f3)
87 total=$(notmuch count '*')
88 notmuch tag +4EFC743A.3060609@april.org id:4EFC743A.3060609@april.org
89 subtotal=$(notmuch count lastmod:..$lastmod)
90 result=$(($subtotal == $total-1))
91 test_expect_equal 1 "$result"