]> git.notmuchmail.org Git - notmuch/blob - test/T060-count.sh
test: renamed test scripts to format T\d\d\d-name.sh
[notmuch] / test / T060-count.sh
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 "files count"
32 test_expect_equal \
33     "$((`notmuch search --output=files '*' | wc -l`))" \
34     "`notmuch count --output=files '*'`"
35
36 test_begin_subtest "files count for a duplicate message-id"
37 test_expect_equal \
38     "2" \
39     "`notmuch count --output=files id:20091117232137.GA7669@griffis1.net`"
40
41 test_begin_subtest "count with no matching messages"
42 test_expect_equal \
43     "0" \
44     "`notmuch count --output=messages from:cworth and not from:cworth`"
45
46 test_begin_subtest "count with no matching threads"
47 test_expect_equal \
48     "0" \
49     "`notmuch count --output=threads from:cworth and not from:cworth`"
50
51 test_begin_subtest "message count is the default for batch count"
52 notmuch count --batch >OUTPUT <<EOF
53
54 from:cworth
55 EOF
56 notmuch count --output=messages >EXPECTED
57 notmuch count --output=messages from:cworth >>EXPECTED
58 test_expect_equal_file EXPECTED OUTPUT
59
60 test_begin_subtest "batch message count"
61 notmuch count --batch --output=messages >OUTPUT <<EOF
62 from:cworth
63
64 tag:inbox
65 EOF
66 notmuch count --output=messages from:cworth >EXPECTED
67 notmuch count --output=messages >>EXPECTED
68 notmuch count --output=messages tag:inbox >>EXPECTED
69 test_expect_equal_file EXPECTED OUTPUT
70
71 test_begin_subtest "batch thread count"
72 notmuch count --batch --output=threads >OUTPUT <<EOF
73
74 from:cworth
75 from:cworth and not from:cworth
76 foo
77 EOF
78 notmuch count --output=threads >EXPECTED
79 notmuch count --output=threads from:cworth >>EXPECTED
80 notmuch count --output=threads from:cworth and not from:cworth >>EXPECTED
81 notmuch count --output=threads foo >>EXPECTED
82 test_expect_equal_file EXPECTED OUTPUT
83
84 test_begin_subtest "batch message count with input file"
85 cat >INPUT <<EOF
86 from:cworth
87
88 tag:inbox
89 EOF
90 notmuch count --input=INPUT --output=messages >OUTPUT
91 notmuch count --output=messages from:cworth >EXPECTED
92 notmuch count --output=messages >>EXPECTED
93 notmuch count --output=messages tag:inbox >>EXPECTED
94 test_expect_equal_file EXPECTED OUTPUT
95
96
97 test_done