]> git.cworth.org Git - obsolete/notmuch-old/blob - test/reply
cli: add --output=files option to notmuch count
[obsolete/notmuch-old] / test / reply
1 #!/usr/bin/env bash
2 test_description="\"notmuch reply\" in several variations"
3 . ./test-lib.sh
4
5 test_begin_subtest "Basic reply"
6 add_message '[from]="Sender <sender@example.com>"' \
7              [to]=test_suite@notmuchmail.org \
8              [subject]=notmuch-reply-test \
9             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
10             '[body]="basic reply test"'
11
12 output=$(notmuch reply id:${gen_msg_id})
13 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
14 Subject: Re: notmuch-reply-test
15 To: Sender <sender@example.com>
16 In-Reply-To: <${gen_msg_id}>
17 References: <${gen_msg_id}>
18
19 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
20 > basic reply test"
21
22 test_begin_subtest "Multiple recipients"
23 add_message '[from]="Sender <sender@example.com>"' \
24             '[to]="test_suite@notmuchmail.org, Someone Else <someone@example.com>"' \
25              [subject]=notmuch-reply-test \
26             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
27             '[body]="Multiple recipients"'
28
29 output=$(notmuch reply id:${gen_msg_id})
30 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
31 Subject: Re: notmuch-reply-test
32 To: Sender <sender@example.com>, Someone Else <someone@example.com>
33 In-Reply-To: <${gen_msg_id}>
34 References: <${gen_msg_id}>
35
36 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
37 > Multiple recipients"
38
39 test_begin_subtest "Reply with CC"
40 add_message '[from]="Sender <sender@example.com>"' \
41              [to]=test_suite@notmuchmail.org \
42             '[cc]="Other Parties <cc@example.com>"' \
43              [subject]=notmuch-reply-test \
44             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
45             '[body]="reply with CC"'
46
47 output=$(notmuch reply id:${gen_msg_id})
48 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
49 Subject: Re: notmuch-reply-test
50 To: Sender <sender@example.com>
51 Cc: Other Parties <cc@example.com>
52 In-Reply-To: <${gen_msg_id}>
53 References: <${gen_msg_id}>
54
55 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
56 > reply with CC"
57
58 test_begin_subtest "Reply from alternate address"
59 add_message '[from]="Sender <sender@example.com>"' \
60              [to]=test_suite_other@notmuchmail.org \
61              [subject]=notmuch-reply-test \
62             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
63             '[body]="reply from alternate address"'
64
65 output=$(notmuch reply id:${gen_msg_id})
66 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
67 Subject: Re: notmuch-reply-test
68 To: Sender <sender@example.com>
69 In-Reply-To: <${gen_msg_id}>
70 References: <${gen_msg_id}>
71
72 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
73 > reply from alternate address"
74
75 test_begin_subtest "Reply from address in named group list"
76 add_message '[from]="Sender <sender@example.com>"' \
77             '[to]=group:test_suite@notmuchmail.org,someone@example.com\;' \
78              [cc]=test_suite_other@notmuchmail.org \
79              [subject]=notmuch-reply-test \
80             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
81             '[body]="Reply from address in named group list"'
82
83 output=$(notmuch reply id:${gen_msg_id})
84 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
85 Subject: Re: notmuch-reply-test
86 To: Sender <sender@example.com>, someone@example.com
87 In-Reply-To: <${gen_msg_id}>
88 References: <${gen_msg_id}>
89
90 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
91 > Reply from address in named group list"
92
93 test_begin_subtest "Support for Reply-To"
94 add_message '[from]="Sender <sender@example.com>"' \
95              [to]=test_suite@notmuchmail.org \
96              [subject]=notmuch-reply-test \
97             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
98             '[body]="support for reply-to"' \
99             '[reply-to]="Sender <elsewhere@example.com>"'
100
101 output=$(notmuch reply id:${gen_msg_id})
102 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
103 Subject: Re: notmuch-reply-test
104 To: Sender <elsewhere@example.com>
105 In-Reply-To: <${gen_msg_id}>
106 References: <${gen_msg_id}>
107
108 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
109 > support for reply-to"
110
111 test_begin_subtest "Un-munging Reply-To"
112 add_message '[from]="Sender <sender@example.com>"' \
113             '[to]="Some List <list@example.com>"' \
114              [subject]=notmuch-reply-test \
115             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
116             '[body]="Un-munging Reply-To"' \
117             '[reply-to]="Evil Munging List <list@example.com>"'
118
119 output=$(notmuch reply id:${gen_msg_id})
120 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
121 Subject: Re: notmuch-reply-test
122 To: Sender <sender@example.com>, Some List <list@example.com>
123 In-Reply-To: <${gen_msg_id}>
124 References: <${gen_msg_id}>
125
126 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
127 > Un-munging Reply-To"
128
129 test_begin_subtest "Message with header of exactly 200 bytes"
130 add_message '[subject]="This subject is exactly 200 bytes in length. Other than its length there is not much of note here. Note that the length of 200 bytes includes the Subject: and Re: prefixes with two spaces"' \
131             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
132             '[body]="200-byte header"'
133 output=$(notmuch reply id:${gen_msg_id})
134 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
135 Subject: Re: This subject is exactly 200 bytes in length. Other than its
136  length there is not much of note here. Note that the length of 200 bytes
137  includes the Subject: and Re: prefixes with two spaces
138 In-Reply-To: <${gen_msg_id}>
139 References: <${gen_msg_id}>
140
141 On Tue, 05 Jan 2010 15:43:56 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
142 > 200-byte header"
143
144 test_begin_subtest "From guessing: Envelope-To"
145 add_message '[from]="Sender <sender@example.com>"' \
146             '[to]="Recipient <recipient@example.com>"' \
147             '[subject]="From guessing"' \
148             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
149             '[body]="From guessing"' \
150             '[header]="Envelope-To: test_suite_other@notmuchmail.org"'
151
152 output=$(notmuch reply id:${gen_msg_id})
153 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
154 Subject: Re: From guessing
155 To: Sender <sender@example.com>, Recipient <recipient@example.com>
156 In-Reply-To: <${gen_msg_id}>
157 References: <${gen_msg_id}>
158
159 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
160 > From guessing"
161
162 test_begin_subtest "From guessing: X-Original-To"
163 add_message '[from]="Sender <sender@example.com>"' \
164             '[to]="Recipient <recipient@example.com>"' \
165             '[subject]="From guessing"' \
166             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
167             '[body]="From guessing"' \
168             '[header]="X-Original-To: test_suite@otherdomain.org"'
169
170 output=$(notmuch reply id:${gen_msg_id})
171 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@otherdomain.org>
172 Subject: Re: From guessing
173 To: Sender <sender@example.com>, Recipient <recipient@example.com>
174 In-Reply-To: <${gen_msg_id}>
175 References: <${gen_msg_id}>
176
177 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
178 > From guessing"
179
180 test_begin_subtest "From guessing: Delivered-To"
181 add_message '[from]="Sender <sender@example.com>"' \
182             '[to]="Recipient <recipient@example.com>"' \
183             '[subject]="From guessing"' \
184             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
185             '[body]="From guessing"' \
186             '[header]="Delivered-To: test_suite_other@notmuchmail.org"'
187
188 output=$(notmuch reply id:${gen_msg_id})
189 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
190 Subject: Re: From guessing
191 To: Sender <sender@example.com>, Recipient <recipient@example.com>
192 In-Reply-To: <${gen_msg_id}>
193 References: <${gen_msg_id}>
194
195 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
196 > From guessing"
197
198 test_begin_subtest "Reply with RFC 2047-encoded headers"
199 add_message '[subject]="=?iso-8859-1?q?=e0=df=e7?="' \
200             '[from]="=?utf-8?q?=e2=98=83?= <snowman@example.com>"' \
201             '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
202             '[body]="Encoding"'
203
204 # GMime happens to change from Q- to B-encoding.  We canonicalize the
205 # case of the encoding and charset because different versions of GMime
206 # capitalize the encoding differently.
207 output=$(notmuch reply id:${gen_msg_id} | perl -pe 's/=\?[^?]+\?[bB]\?/lc($&)/ge')
208 test_expect_equal "$output" "\
209 From: Notmuch Test Suite <test_suite@notmuchmail.org>
210 Subject: Re: =?iso-8859-1?b?4N/n?=
211 To: =?utf-8?b?4piD?= <snowman@example.com>
212 In-Reply-To: <${gen_msg_id}>
213 References: <${gen_msg_id}>
214
215 On Tue, 05 Jan 2010 15:43:56 -0000, ☃ <snowman@example.com> wrote:
216 > Encoding"
217
218 test_begin_subtest "Reply with RFC 2047-encoded headers (JSON)"
219 output=$(notmuch reply --format=json id:${gen_msg_id})
220 test_expect_equal_json "$output" '
221 {
222     "original": {
223         "body": [
224             {
225                 "content": "Encoding\n",
226                 "content-type": "text/plain",
227                 "id": 1
228             }
229         ],
230         "date_relative": "2010-01-05",
231         "excluded": false,
232         "filename": "'${MAIL_DIR}'/msg-012",
233         "headers": {
234             "Date": "Tue, 05 Jan 2010 15:43:56 +0000",
235             "From": "\u2603 <snowman@example.com>",
236             "Subject": "\u00e0\u00df\u00e7",
237             "To": "Notmuch Test Suite <test_suite@notmuchmail.org>"
238         },
239         "id": "'${gen_msg_id}'",
240         "match": false,
241         "tags": [
242             "inbox",
243             "unread"
244         ],
245         "timestamp": 1262706236
246     },
247     "reply-headers": {
248         "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
249         "In-reply-to": "<'${gen_msg_id}'>",
250         "References": "<'${gen_msg_id}'>",
251         "Subject": "Re: \u00e0\u00df\u00e7",
252         "To": "\u2603 <snowman@example.com>"
253     }
254 }'
255
256
257 test_done