]> git.cworth.org Git - notmuch-old/blob - test/T520-show.sh
CLI/git: add safety checks for checkout and commit
[notmuch-old] / test / T520-show.sh
1 #!/usr/bin/env bash
2 test_description='"notmuch show"'
3
4 . $(dirname "$0")/test-lib.sh || exit 1
5
6 test_query_syntax () {
7     test_begin_subtest "sexpr query: $1"
8     sexp=$(notmuch show --format=json --query=sexp "$1")
9     infix=$(notmuch show --format=json "$2")
10     test_expect_equal_json "$sexp" "$infix"
11 }
12
13 add_email_corpus
14
15 test_begin_subtest "exit code for show invalid query"
16 notmuch show foo..
17 exit_code=$?
18 test_expect_equal 1 $exit_code
19
20 test_begin_subtest "notmuch show --sort=newest-first"
21 notmuch show --entire-thread=true '*' > EXPECTED
22 notmuch show --entire-thread=true --sort=newest-first '*' > OUTPUT
23 test_expect_equal_file EXPECTED OUTPUT
24
25 test_begin_subtest "notmuch show --sort=oldest-first"
26 notmuch show --entire-thread=true '*' | grep ^depth:0 > EXPECTED
27 notmuch show --entire-thread=true --sort=oldest-first '*' | grep ^depth:0 > OLDEST
28 perl -e 'print reverse<>' OLDEST > OUTPUT
29 test_expect_equal_file EXPECTED OUTPUT
30
31 test_begin_subtest "notmuch show --sort for single thread"
32 QUERY="id:yun1vjwegii.fsf@aiko.keithp.com"
33 notmuch show --entire-thread=true --sort=newest-first $QUERY > EXPECTED
34 notmuch show --entire-thread=true --sort=oldest-first $QUERY > OUTPUT
35 test_expect_equal_file EXPECTED OUTPUT
36
37
38 if [ $NOTMUCH_HAVE_SFSEXP -eq 1 ]; then
39
40     test_query_syntax '(and "wonderful" "wizard")' 'wonderful and wizard'
41     test_query_syntax '(or "php" "wizard")' 'php or wizard'
42     test_query_syntax 'wizard' 'wizard'
43     test_query_syntax 'Wizard' 'Wizard'
44     test_query_syntax '(attachment notmuch-help.patch)' 'attachment:notmuch-help.patch'
45
46 fi
47
48 test_done