1554eb1e93f32c7f84d461eec7687f7c43f8d220
[notmuch] / test / search-output
1 #!/usr/bin/env bash
2 test_description='various settings for "notmuch search --output="'
3 . ./test-lib.sh
4
5 add_email_corpus
6
7 test_begin_subtest "notmuch search --output=threads"
8 notmuch search --output=threads '*' | sed -e s/thread:.*/thread:THREADID/ >OUTPUT
9 cat <<EOF >EXPECTED
10 thread:THREADID
11 thread:THREADID
12 thread:THREADID
13 thread:THREADID
14 thread:THREADID
15 thread:THREADID
16 thread:THREADID
17 thread:THREADID
18 thread:THREADID
19 thread:THREADID
20 thread:THREADID
21 thread:THREADID
22 thread:THREADID
23 thread:THREADID
24 thread:THREADID
25 thread:THREADID
26 thread:THREADID
27 thread:THREADID
28 thread:THREADID
29 thread:THREADID
30 thread:THREADID
31 thread:THREADID
32 EOF
33 test_expect_equal_file OUTPUT EXPECTED
34
35 test_begin_subtest "notmuch search --format=json --output=threads"
36 notmuch search --format=json --output=threads '*' | sed -e s/\".*\"/\"THREADID\"/ >OUTPUT
37 cat <<EOF >EXPECTED
38 ["THREADID",
39 "THREADID",
40 "THREADID",
41 "THREADID",
42 "THREADID",
43 "THREADID",
44 "THREADID",
45 "THREADID",
46 "THREADID",
47 "THREADID",
48 "THREADID",
49 "THREADID",
50 "THREADID",
51 "THREADID",
52 "THREADID",
53 "THREADID",
54 "THREADID",
55 "THREADID",
56 "THREADID",
57 "THREADID",
58 "THREADID",
59 "THREADID"]
60 EOF
61 test_expect_equal_file OUTPUT EXPECTED
62
63 test_begin_subtest "notmuch search --output=messages"
64 notmuch search --output=messages '*' >OUTPUT
65 cat <<EOF >EXPECTED
66 id:1258544095-16616-1-git-send-email-chris@chris-wilson.co.uk
67 id:877htoqdbo.fsf@yoom.home.cworth.org
68 id:878we4qdqf.fsf@yoom.home.cworth.org
69 id:87aaykqe24.fsf@yoom.home.cworth.org
70 id:87bpj0qeng.fsf@yoom.home.cworth.org
71 id:87fx8cqf8v.fsf@yoom.home.cworth.org
72 id:87hbssqfix.fsf@yoom.home.cworth.org
73 id:87iqd8qgiz.fsf@yoom.home.cworth.org
74 id:87k4xoqgnl.fsf@yoom.home.cworth.org
75 id:87ocn0qh6d.fsf@yoom.home.cworth.org
76 id:87pr7gqidx.fsf@yoom.home.cworth.org
77 id:867hto2p0t.fsf@fortitudo.i-did-not-set--mail-host-address--so-tickle-me
78 id:1258532999-9316-1-git-send-email-keithp@keithp.com
79 id:86aayk2rbj.fsf@fortitudo.i-did-not-set--mail-host-address--so-tickle-me
80 id:86d43g2w3y.fsf@fortitudo.i-did-not-set--mail-host-address--so-tickle-me
81 id:ddd65cda0911172214t60d22b63hcfeb5a19ab54a39b@mail.gmail.com
82 id:86einw2xof.fsf@fortitudo.i-did-not-set--mail-host-address--so-tickle-me
83 id:736613.51770.qm@web113505.mail.gq1.yahoo.com
84 id:1258520223-15328-1-git-send-email-jan@ryngle.com
85 id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com
86 id:1258510940-7018-1-git-send-email-stewart@flamingspork.com
87 id:yunzl6kd1w0.fsf@aiko.keithp.com
88 id:yun1vjwegii.fsf@aiko.keithp.com
89 id:yun3a4cegoa.fsf@aiko.keithp.com
90 id:1258509400-32511-1-git-send-email-stewart@flamingspork.com
91 id:1258506353-20352-1-git-send-email-stewart@flamingspork.com
92 id:20091118010116.GC25380@dottiness.seas.harvard.edu
93 id:20091118005829.GB25380@dottiness.seas.harvard.edu
94 id:20091118005040.GA25380@dottiness.seas.harvard.edu
95 id:cf0c4d610911171623q3e27a0adx802e47039b57604b@mail.gmail.com
96 id:1258500222-32066-1-git-send-email-ingmar@exherbo.org
97 id:20091117232137.GA7669@griffis1.net
98 id:20091118002059.067214ed@hikari
99 id:1258498485-sup-142@elly
100 id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com
101 id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com
102 id:1258496327-12086-1-git-send-email-jan@ryngle.com
103 id:1258493565-13508-1-git-send-email-keithp@keithp.com
104 id:yunaayketfm.fsf@aiko.keithp.com
105 id:yunbpj0etua.fsf@aiko.keithp.com
106 id:1258491078-29658-1-git-send-email-dottedmag@dottedmag.net
107 id:87fx8can9z.fsf@vertex.dottedmag
108 id:20091117203301.GV3165@dottiness.seas.harvard.edu
109 id:87lji4lx9v.fsf@yoom.home.cworth.org
110 id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com
111 id:87iqd9rn3l.fsf@vertex.dottedmag
112 id:20091117190054.GU3165@dottiness.seas.harvard.edu
113 id:87lji5cbwo.fsf@yoom.home.cworth.org
114 id:1258471718-6781-2-git-send-email-dottedmag@dottedmag.net
115 id:1258471718-6781-1-git-send-email-dottedmag@dottedmag.net
116 EOF
117 test_expect_equal_file OUTPUT EXPECTED
118
119 test_begin_subtest "notmuch search --format=json --output=messages"
120 notmuch search --format=json --output=messages '*' >OUTPUT
121 cat <<EOF >EXPECTED
122 ["1258544095-16616-1-git-send-email-chris@chris-wilson.co.uk",
123 "877htoqdbo.fsf@yoom.home.cworth.org",
124 "878we4qdqf.fsf@yoom.home.cworth.org",
125 "87aaykqe24.fsf@yoom.home.cworth.org",
126 "87bpj0qeng.fsf@yoom.home.cworth.org",
127 "87fx8cqf8v.fsf@yoom.home.cworth.org",
128 "87hbssqfix.fsf@yoom.home.cworth.org",
129 "87iqd8qgiz.fsf@yoom.home.cworth.org",
130 "87k4xoqgnl.fsf@yoom.home.cworth.org",
131 "87ocn0qh6d.fsf@yoom.home.cworth.org",
132 "87pr7gqidx.fsf@yoom.home.cworth.org",
133 "867hto2p0t.fsf@fortitudo.i-did-not-set--mail-host-address--so-tickle-me",
134 "1258532999-9316-1-git-send-email-keithp@keithp.com",
135 "86aayk2rbj.fsf@fortitudo.i-did-not-set--mail-host-address--so-tickle-me",
136 "86d43g2w3y.fsf@fortitudo.i-did-not-set--mail-host-address--so-tickle-me",
137 "ddd65cda0911172214t60d22b63hcfeb5a19ab54a39b@mail.gmail.com",
138 "86einw2xof.fsf@fortitudo.i-did-not-set--mail-host-address--so-tickle-me",
139 "736613.51770.qm@web113505.mail.gq1.yahoo.com",
140 "1258520223-15328-1-git-send-email-jan@ryngle.com",
141 "ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com",
142 "1258510940-7018-1-git-send-email-stewart@flamingspork.com",
143 "yunzl6kd1w0.fsf@aiko.keithp.com",
144 "yun1vjwegii.fsf@aiko.keithp.com",
145 "yun3a4cegoa.fsf@aiko.keithp.com",
146 "1258509400-32511-1-git-send-email-stewart@flamingspork.com",
147 "1258506353-20352-1-git-send-email-stewart@flamingspork.com",
148 "20091118010116.GC25380@dottiness.seas.harvard.edu",
149 "20091118005829.GB25380@dottiness.seas.harvard.edu",
150 "20091118005040.GA25380@dottiness.seas.harvard.edu",
151 "cf0c4d610911171623q3e27a0adx802e47039b57604b@mail.gmail.com",
152 "1258500222-32066-1-git-send-email-ingmar@exherbo.org",
153 "20091117232137.GA7669@griffis1.net",
154 "20091118002059.067214ed@hikari",
155 "1258498485-sup-142@elly",
156 "f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com",
157 "f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com",
158 "1258496327-12086-1-git-send-email-jan@ryngle.com",
159 "1258493565-13508-1-git-send-email-keithp@keithp.com",
160 "yunaayketfm.fsf@aiko.keithp.com",
161 "yunbpj0etua.fsf@aiko.keithp.com",
162 "1258491078-29658-1-git-send-email-dottedmag@dottedmag.net",
163 "87fx8can9z.fsf@vertex.dottedmag",
164 "20091117203301.GV3165@dottiness.seas.harvard.edu",
165 "87lji4lx9v.fsf@yoom.home.cworth.org",
166 "cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com",
167 "87iqd9rn3l.fsf@vertex.dottedmag",
168 "20091117190054.GU3165@dottiness.seas.harvard.edu",
169 "87lji5cbwo.fsf@yoom.home.cworth.org",
170 "1258471718-6781-2-git-send-email-dottedmag@dottedmag.net",
171 "1258471718-6781-1-git-send-email-dottedmag@dottedmag.net"]
172 EOF
173 test_expect_equal_file OUTPUT EXPECTED
174
175 test_begin_subtest "notmuch search --output=files"
176 notmuch search --output=files '*' | sed -e "s,$MAIL_DIR,MAIL_DIR," >OUTPUT
177 cat <<EOF >EXPECTED
178 MAIL_DIR/cur/50:2,
179 MAIL_DIR/cur/49:2,
180 MAIL_DIR/cur/48:2,
181 MAIL_DIR/cur/47:2,
182 MAIL_DIR/cur/46:2,
183 MAIL_DIR/cur/45:2,
184 MAIL_DIR/cur/44:2,
185 MAIL_DIR/cur/43:2,
186 MAIL_DIR/cur/42:2,
187 MAIL_DIR/cur/41:2,
188 MAIL_DIR/cur/40:2,
189 MAIL_DIR/cur/39:2,
190 MAIL_DIR/cur/38:2,
191 MAIL_DIR/cur/37:2,
192 MAIL_DIR/cur/36:2,
193 MAIL_DIR/cur/35:2,
194 MAIL_DIR/cur/34:2,
195 MAIL_DIR/cur/33:2,
196 MAIL_DIR/cur/32:2,
197 MAIL_DIR/cur/31:2,
198 MAIL_DIR/cur/30:2,
199 MAIL_DIR/cur/29:2,
200 MAIL_DIR/cur/28:2,
201 MAIL_DIR/cur/27:2,
202 MAIL_DIR/cur/26:2,
203 MAIL_DIR/cur/25:2,
204 MAIL_DIR/cur/24:2,
205 MAIL_DIR/cur/23:2,
206 MAIL_DIR/cur/22:2,
207 MAIL_DIR/cur/21:2,
208 MAIL_DIR/cur/19:2,
209 MAIL_DIR/cur/18:2,
210 MAIL_DIR/cur/20:2,
211 MAIL_DIR/cur/17:2,
212 MAIL_DIR/cur/16:2,
213 MAIL_DIR/cur/15:2,
214 MAIL_DIR/cur/14:2,
215 MAIL_DIR/cur/13:2,
216 MAIL_DIR/cur/12:2,
217 MAIL_DIR/cur/11:2,
218 MAIL_DIR/cur/10:2,
219 MAIL_DIR/cur/09:2,
220 MAIL_DIR/cur/08:2,
221 MAIL_DIR/cur/06:2,
222 MAIL_DIR/cur/05:2,
223 MAIL_DIR/cur/04:2,
224 MAIL_DIR/cur/03:2,
225 MAIL_DIR/cur/07:2,
226 MAIL_DIR/cur/02:2,
227 MAIL_DIR/cur/01:2,
228 EOF
229 test_expect_equal_file OUTPUT EXPECTED
230
231 test_begin_subtest "notmuch search --format=json --output=files"
232 notmuch search --format=json --output=files '*' | sed -e "s,$MAIL_DIR,MAIL_DIR," >OUTPUT
233 cat <<EOF >EXPECTED
234 ["MAIL_DIR/cur/50:2,",
235 "MAIL_DIR/cur/49:2,",
236 "MAIL_DIR/cur/48:2,",
237 "MAIL_DIR/cur/47:2,",
238 "MAIL_DIR/cur/46:2,",
239 "MAIL_DIR/cur/45:2,",
240 "MAIL_DIR/cur/44:2,",
241 "MAIL_DIR/cur/43:2,",
242 "MAIL_DIR/cur/42:2,",
243 "MAIL_DIR/cur/41:2,",
244 "MAIL_DIR/cur/40:2,",
245 "MAIL_DIR/cur/39:2,",
246 "MAIL_DIR/cur/38:2,",
247 "MAIL_DIR/cur/37:2,",
248 "MAIL_DIR/cur/36:2,",
249 "MAIL_DIR/cur/35:2,",
250 "MAIL_DIR/cur/34:2,",
251 "MAIL_DIR/cur/33:2,",
252 "MAIL_DIR/cur/32:2,",
253 "MAIL_DIR/cur/31:2,",
254 "MAIL_DIR/cur/30:2,",
255 "MAIL_DIR/cur/29:2,",
256 "MAIL_DIR/cur/28:2,",
257 "MAIL_DIR/cur/27:2,",
258 "MAIL_DIR/cur/26:2,",
259 "MAIL_DIR/cur/25:2,",
260 "MAIL_DIR/cur/24:2,",
261 "MAIL_DIR/cur/23:2,",
262 "MAIL_DIR/cur/22:2,",
263 "MAIL_DIR/cur/21:2,",
264 "MAIL_DIR/cur/19:2,",
265 "MAIL_DIR/cur/18:2,",
266 "MAIL_DIR/cur/20:2,",
267 "MAIL_DIR/cur/17:2,",
268 "MAIL_DIR/cur/16:2,",
269 "MAIL_DIR/cur/15:2,",
270 "MAIL_DIR/cur/14:2,",
271 "MAIL_DIR/cur/13:2,",
272 "MAIL_DIR/cur/12:2,",
273 "MAIL_DIR/cur/11:2,",
274 "MAIL_DIR/cur/10:2,",
275 "MAIL_DIR/cur/09:2,",
276 "MAIL_DIR/cur/08:2,",
277 "MAIL_DIR/cur/06:2,",
278 "MAIL_DIR/cur/05:2,",
279 "MAIL_DIR/cur/04:2,",
280 "MAIL_DIR/cur/03:2,",
281 "MAIL_DIR/cur/07:2,",
282 "MAIL_DIR/cur/02:2,",
283 "MAIL_DIR/cur/01:2,"]
284 EOF
285 test_expect_equal_file OUTPUT EXPECTED
286
287 test_begin_subtest "notmuch search --output=tags"
288 notmuch search --output=tags '*' >OUTPUT
289 cat <<EOF >EXPECTED
290 attachment
291 inbox
292 signed
293 unread
294 EOF
295 test_expect_equal_file OUTPUT EXPECTED
296
297 test_begin_subtest "notmuch search --format=json --output=tags"
298 notmuch search --format=json --output=tags '*' >OUTPUT
299 cat <<EOF >EXPECTED
300 ["attachment",
301 "inbox",
302 "signed",
303 "unread"]
304 EOF
305 test_expect_equal_file OUTPUT EXPECTED
306
307 test_done