File: T580-thread-search.sh

package info (click to toggle)
notmuch 0.39-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,104 kB
  • sloc: sh: 21,888; ansic: 14,897; lisp: 9,061; cpp: 7,990; python: 6,221; perl: 391; makefile: 231; javascript: 34; ruby: 13
file content (42 lines) | stat: -rwxr-xr-x 915 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
#
# Copyright (c) 2015 David Bremner
#

test_description='test of searching by thread-id'

. $(dirname "$0")/test-lib.sh || exit 1

add_email_corpus

test_begin_subtest "Every message is found in exactly one thread"

count=0
success=0
for id in $(notmuch search --output=messages '*'); do
    count=$((count +1))
    matches=$((`notmuch search --output=threads "$id" | wc -l`))
    if [ "$matches" = 1 ]; then
	success=$((success + 1))
    fi
done

test_expect_equal "$count" "$success"

test_begin_subtest "roundtripping message-ids via thread-ids"

count=0
success=0
for id in $(notmuch search --output=messages '*'); do
    count=$((count +1))
    thread=$(notmuch search --output=threads "$id")
    matched=$(notmuch search --output=messages "$thread" | grep "$id")
    if [ "$matched" = "$id" ]; then
	success=$((success + 1))
    fi
done

test_expect_equal "$count" "$success"


test_done