]> git.notmuchmail.org Git - notmuch/blob - test/text
test: basic: drop 'ensure all available tests are run'
[notmuch] / test / text
1 #!/usr/bin/env bash
2 test_description="--format=text output"
3 . ./test-lib.sh
4
5 test_begin_subtest "Show message: text"
6 add_message "[subject]=\"text-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"text-show-message\""
7 output=$(notmuch show --format=text "text-show-message" | notmuch_show_sanitize_all)
8 test_expect_equal "$output" "\
9 \fmessage{ id:XXXXX depth:0 match:1 excluded:0 filename:XXXXX
10 \fheader{
11 Notmuch Test Suite <test_suite@notmuchmail.org> (2000-01-01) (inbox unread)
12 Subject: text-show-subject
13 From: Notmuch Test Suite <test_suite@notmuchmail.org>
14 To: Notmuch Test Suite <test_suite@notmuchmail.org>
15 Date: Sat, 01 Jan 2000 12:00:00 +0000
16 \fheader}
17 \fbody{
18 \fpart{ ID: 1, Content-type: text/plain
19 text-show-message
20 \fpart}
21 \fbody}
22 \fmessage}"
23
24 test_begin_subtest "Search message: text"
25 add_message "[subject]=\"text-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"text-search-message\""
26 output=$(notmuch search --format=text "text-search-message" | notmuch_search_sanitize)
27 test_expect_equal "$output" \
28 "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; text-search-subject (inbox unread)"
29
30 test_begin_subtest "Show message: text, utf-8"
31 add_message "[subject]=\"text-show-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"tëxt-show-méssage\""
32 output=$(notmuch show --format=text "tëxt-show-méssage" | notmuch_show_sanitize_all)
33 test_expect_equal "$output" "\
34 \fmessage{ id:XXXXX depth:0 match:1 excluded:0 filename:XXXXX
35 \fheader{
36 Notmuch Test Suite <test_suite@notmuchmail.org> (2000-01-01) (inbox unread)
37 Subject: text-show-utf8-body-sübjéct
38 From: Notmuch Test Suite <test_suite@notmuchmail.org>
39 To: Notmuch Test Suite <test_suite@notmuchmail.org>
40 Date: Sat, 01 Jan 2000 12:00:00 +0000
41 \fheader}
42 \fbody{
43 \fpart{ ID: 1, Content-type: text/plain
44 tëxt-show-méssage
45 \fpart}
46 \fbody}
47 \fmessage}"
48
49 test_begin_subtest "Search message: text, utf-8"
50 add_message "[subject]=\"text-search-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"tëxt-search-méssage\""
51 output=$(notmuch search --format=text "tëxt-search-méssage" | notmuch_search_sanitize)
52 test_expect_equal "$output" \
53 "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; text-search-utf8-body-sübjéct (inbox unread)"
54
55 add_email_corpus
56
57 test_begin_subtest "Search message tags: text0"
58 cat <<EOF > EXPECTED
59 attachment inbox signed unread
60 EOF
61 notmuch search --format=text0 --output=tags '*' | xargs -0 | notmuch_search_sanitize > OUTPUT
62 test_expect_equal_file EXPECTED OUTPUT
63
64 # Use tr(1) to convert --output=text0 to --output=text for
65 # comparison. Also translate newlines to spaces to fail with more
66 # noise if they are present as delimiters instead of null
67 # characters. This assumes there are no newlines in the data.
68 test_begin_subtest "Compare text vs. text0 for threads"
69 notmuch search --format=text --output=threads '*' | notmuch_search_sanitize > EXPECTED
70 notmuch search --format=text0 --output=threads '*' | tr "\n\0" " \n" | notmuch_search_sanitize > OUTPUT
71 test_expect_equal_file EXPECTED OUTPUT
72
73 test_begin_subtest "Compare text vs. text0 for messages"
74 notmuch search --format=text --output=messages '*' | notmuch_search_sanitize > EXPECTED
75 notmuch search --format=text0 --output=messages '*' | tr "\n\0" " \n" | notmuch_search_sanitize > OUTPUT
76 test_expect_equal_file EXPECTED OUTPUT
77
78 test_begin_subtest "Compare text vs. text0 for files"
79 notmuch search --format=text --output=files '*' | notmuch_search_sanitize > EXPECTED
80 notmuch search --format=text0 --output=files '*' | tr "\n\0" " \n" | notmuch_search_sanitize > OUTPUT
81 test_expect_equal_file EXPECTED OUTPUT
82
83 test_begin_subtest "Compare text vs. text0 for tags"
84 notmuch search --format=text --output=tags '*' | notmuch_search_sanitize > EXPECTED
85 notmuch search --format=text0 --output=tags '*' | tr "\n\0" " \n" | notmuch_search_sanitize > OUTPUT
86 test_expect_equal_file EXPECTED OUTPUT
87
88 test_done