]> git.cworth.org Git - obsolete/notmuch-old/blob - test/count
Merge tag '0.12'
[obsolete/notmuch-old] / test / count
1 #!/usr/bin/env bash
2 test_description='"notmuch count" for messages and threads'
3 . ./test-lib.sh
4
5 add_email_corpus
6
7 SEARCH="\"*\""
8
9 test_begin_subtest "message count is the default for notmuch count"
10 test_expect_equal \
11     "`notmuch search --output=messages ${SEARCH} | wc -l`" \
12     "`notmuch count ${SEARCH}`"
13
14 test_begin_subtest "message count with --output=messages"
15 test_expect_equal \
16     "`notmuch search --output=messages ${SEARCH} | wc -l`" \
17     "`notmuch count --output=messages ${SEARCH}`"
18
19 test_begin_subtest "thread count with --output=threads"
20 test_expect_equal \
21     "`notmuch search --output=threads ${SEARCH} | wc -l`" \
22     "`notmuch count --output=threads ${SEARCH}`"
23
24 test_begin_subtest "thread count is the default for notmuch search"
25 test_expect_equal \
26     "`notmuch search ${SEARCH} | wc -l`" \
27     "`notmuch count --output=threads ${SEARCH}`"
28
29 SEARCH="from:cworth and not from:cworth"
30 test_begin_subtest "count with no matching messages"
31 test_expect_equal \
32     "0" \
33     "`notmuch count --output=messages ${SEARCH}`"
34
35 test_begin_subtest "count with no matching threads"
36 test_expect_equal \
37     "0" \
38     "`notmuch count --output=threads ${SEARCH}`"
39
40 test_begin_subtest "count excluding \"deleted\" messages"
41 notmuch config set search.exclude_tags deleted
42 generate_message '[subject]="Not deleted"'
43 generate_message '[subject]="Another not deleted"'
44 generate_message '[subject]="Deleted"'
45 notmuch new > /dev/null
46 notmuch tag +deleted id:$gen_msg_id
47 test_expect_equal \
48     "2" \
49     "`notmuch count subject:deleted`"
50
51 test_begin_subtest "count \"deleted\" messages, exclude overridden"
52 test_expect_equal \
53     "1" \
54     "`notmuch count subject:deleted and tag:deleted`"
55
56 test_begin_subtest "count \"deleted\" messages, with --no-exclude"
57 test_expect_equal \
58     "3" \
59     "`notmuch count --no-exclude subject:deleted`"
60
61 test_done