]> git.notmuchmail.org Git - notmuch/blob - test/count
05713fdc7eb250a65b618fbd152846f93d08a134
[notmuch] / 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 # Note: The 'wc -l' results below are wrapped in arithmetic evaluation
8 # $((...)) to strip whitespace. This is for portability, as 'wc -l'
9 # emits whitespace on some BSD variants.
10
11 test_begin_subtest "message count is the default for notmuch count"
12 test_expect_equal \
13     "$((`notmuch search --output=messages '*' | wc -l`))" \
14     "`notmuch count '*'`"
15
16 test_begin_subtest "message count with --output=messages"
17 test_expect_equal \
18     "$((`notmuch search --output=messages '*' | wc -l`))" \
19     "`notmuch count --output=messages '*'`"
20
21 test_begin_subtest "thread count with --output=threads"
22 test_expect_equal \
23     "$((`notmuch search --output=threads '*' | wc -l`))" \
24     "`notmuch count --output=threads '*'`"
25
26 test_begin_subtest "thread count is the default for notmuch search"
27 test_expect_equal \
28     "$((`notmuch search '*' | wc -l`))" \
29     "`notmuch count --output=threads '*'`"
30
31 test_begin_subtest "count with no matching messages"
32 test_expect_equal \
33     "0" \
34     "`notmuch count --output=messages from:cworth and not from:cworth`"
35
36 test_begin_subtest "count with no matching threads"
37 test_expect_equal \
38     "0" \
39     "`notmuch count --output=threads from:cworth and not from:cworth`"
40
41 test_begin_subtest "message count is the default for batch count"
42 notmuch count --batch >OUTPUT <<EOF
43
44 from:cworth
45 EOF
46 notmuch count --output=messages >EXPECTED
47 notmuch count --output=messages from:cworth >>EXPECTED
48 test_expect_equal_file EXPECTED OUTPUT
49
50 test_begin_subtest "batch message count"
51 notmuch count --batch --output=messages >OUTPUT <<EOF
52 from:cworth
53
54 tag:inbox
55 EOF
56 notmuch count --output=messages from:cworth >EXPECTED
57 notmuch count --output=messages >>EXPECTED
58 notmuch count --output=messages tag:inbox >>EXPECTED
59 test_expect_equal_file EXPECTED OUTPUT
60
61 test_begin_subtest "batch thread count"
62 notmuch count --batch --output=threads >OUTPUT <<EOF
63
64 from:cworth
65 from:cworth and not from:cworth
66 foo
67 EOF
68 notmuch count --output=threads >EXPECTED
69 notmuch count --output=threads from:cworth >>EXPECTED
70 notmuch count --output=threads from:cworth and not from:cworth >>EXPECTED
71 notmuch count --output=threads foo >>EXPECTED
72 test_expect_equal_file EXPECTED OUTPUT
73
74 test_begin_subtest "batch message count with input file"
75 cat >INPUT <<EOF
76 from:cworth
77
78 tag:inbox
79 EOF
80 notmuch count --input=INPUT --output=messages >OUTPUT
81 notmuch count --output=messages from:cworth >EXPECTED
82 notmuch count --output=messages >>EXPECTED
83 notmuch count --output=messages tag:inbox >>EXPECTED
84 test_expect_equal_file EXPECTED OUTPUT
85
86
87 test_done