]> git.cworth.org Git - notmuch/blob - test/T585-thread-subquery.sh
Merge branch 'release'
[notmuch] / test / T585-thread-subquery.sh
1 #!/usr/bin/env bash
2 #
3 # Copyright (c) 2018 David Bremner
4 #
5
6 test_description='test of searching by using thread subqueries'
7
8 . $(dirname "$0")/test-lib.sh || exit 1
9
10 add_email_corpus
11
12 test_begin_subtest "Basic query that matches no messages"
13 count=$(notmuch count from:keithp and to:keithp)
14 test_expect_equal 0 "$count"
15
16 test_begin_subtest "Same query against threads"
17 notmuch search thread:{from:keithp} and thread:{to:keithp} | notmuch_search_sanitize > OUTPUT
18 cat<<EOF > EXPECTED
19 thread:XXX   2009-11-18 [7/7] Lars Kellogg-Stedman, Mikhail Gusarov, Keith Packard, Carl Worth; [notmuch] Working with Maildir storage? (inbox signed unread)
20 EOF
21 test_expect_equal_file EXPECTED OUTPUT
22
23 test_begin_subtest "Mix thread and non-threads query"
24 notmuch search thread:{from:keithp} and to:keithp | notmuch_search_sanitize > OUTPUT
25 cat<<EOF > EXPECTED
26 thread:XXX   2009-11-18 [1/7] Lars Kellogg-Stedman| Mikhail Gusarov, Keith Packard, Carl Worth; [notmuch] Working with Maildir storage? (inbox signed unread)
27 EOF
28 test_expect_equal_file EXPECTED OUTPUT
29
30 test_begin_subtest "Compound subquery"
31 notmuch search 'thread:"{from:keithp and date:2009}" and thread:{to:keithp}' | notmuch_search_sanitize > OUTPUT
32 cat<<EOF > EXPECTED
33 thread:XXX   2009-11-18 [7/7] Lars Kellogg-Stedman, Mikhail Gusarov, Keith Packard, Carl Worth; [notmuch] Working with Maildir storage? (inbox signed unread)
34 EOF
35 test_expect_equal_file EXPECTED OUTPUT
36
37 test_begin_subtest "Syntax/quoting error in subquery"
38 notmuch search 'thread:{from:keithp and date:2009} and thread:{to:keithp}' 1>OUTPUT 2>&1
39 cat<<EOF > EXPECTED
40 notmuch search: A Xapian exception occurred
41 A Xapian exception occurred parsing query: missing } in '{from:keithp'
42 Query string was: thread:{from:keithp and date:2009} and thread:{to:keithp}
43 EOF
44 test_expect_equal_file EXPECTED OUTPUT
45
46 test_done