]> git.cworth.org Git - notmuch/blob - test/T580-thread-search.sh
NEWS: At least Emacs 25.1 is required now
[notmuch] / test / T580-thread-search.sh
1 #!/usr/bin/env bash
2 #
3 # Copyright (c) 2015 David Bremner
4 #
5
6 test_description='test of searching by thread-id'
7
8 . $(dirname "$0")/test-lib.sh || exit 1
9
10 add_email_corpus
11
12 test_begin_subtest "Every message is found in exactly one thread"
13
14 count=0
15 success=0
16 for id in $(notmuch search --output=messages '*'); do
17     count=$((count +1))
18     matches=$((`notmuch search --output=threads "$id" | wc -l`))
19     if [ "$matches" = 1 ]; then
20         success=$((success + 1))
21     fi
22 done
23
24 test_expect_equal "$count" "$success"
25
26 test_begin_subtest "roundtripping message-ids via thread-ids"
27
28 count=0
29 success=0
30 for id in $(notmuch search --output=messages '*'); do
31     count=$((count +1))
32     thread=$(notmuch search --output=threads "$id")
33     matched=$(notmuch search --output=messages "$thread" | grep "$id")
34     if [ "$matched" = "$id" ]; then
35         success=$((success + 1))
36     fi
37 done
38
39 test_expect_equal "$count" "$success"
40
41
42 test_done