Skip to content

Commit 2b12e0e

Browse files
committed
✅ Add THREAD tests, using RFC5256 examples
Also updated the YAML test generator
1 parent fdd7282 commit 2b12e0e

File tree

2 files changed

+350
-0
lines changed

2 files changed

+350
-0
lines changed
Lines changed: 347 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,347 @@
1+
---
2+
:tests:
3+
thread_rfc5256_example1:
4+
:response: "* THREAD (166)(167)(168)(169)(172)(170)(171)(173)(174 (175)(176)(178)(181)(180))(179)(177(183)(182)(188)(184)(185)(186)(187)(189))(190)(191)(192)(193)(194
5+
195)(196 (197)(198))(199)(200 202)(201)(203)(204)(205)(206 207)(208)\r\n"
6+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
7+
name: THREAD
8+
data:
9+
- !ruby/struct:Net::IMAP::ThreadMember
10+
seqno: 166
11+
children: []
12+
- !ruby/struct:Net::IMAP::ThreadMember
13+
seqno: 167
14+
children: []
15+
- !ruby/struct:Net::IMAP::ThreadMember
16+
seqno: 168
17+
children: []
18+
- !ruby/struct:Net::IMAP::ThreadMember
19+
seqno: 169
20+
children: []
21+
- !ruby/struct:Net::IMAP::ThreadMember
22+
seqno: 172
23+
children: []
24+
- !ruby/struct:Net::IMAP::ThreadMember
25+
seqno: 170
26+
children: []
27+
- !ruby/struct:Net::IMAP::ThreadMember
28+
seqno: 171
29+
children: []
30+
- !ruby/struct:Net::IMAP::ThreadMember
31+
seqno: 173
32+
children: []
33+
- !ruby/struct:Net::IMAP::ThreadMember
34+
seqno: 174
35+
children:
36+
- !ruby/struct:Net::IMAP::ThreadMember
37+
seqno: 175
38+
children: []
39+
- !ruby/struct:Net::IMAP::ThreadMember
40+
seqno: 176
41+
children: []
42+
- !ruby/struct:Net::IMAP::ThreadMember
43+
seqno: 178
44+
children: []
45+
- !ruby/struct:Net::IMAP::ThreadMember
46+
seqno: 181
47+
children: []
48+
- !ruby/struct:Net::IMAP::ThreadMember
49+
seqno: 180
50+
children: []
51+
- !ruby/struct:Net::IMAP::ThreadMember
52+
seqno: 179
53+
children: []
54+
- !ruby/struct:Net::IMAP::ThreadMember
55+
seqno: 177
56+
children:
57+
- !ruby/struct:Net::IMAP::ThreadMember
58+
seqno: 183
59+
children: []
60+
- !ruby/struct:Net::IMAP::ThreadMember
61+
seqno: 182
62+
children: []
63+
- !ruby/struct:Net::IMAP::ThreadMember
64+
seqno: 188
65+
children: []
66+
- !ruby/struct:Net::IMAP::ThreadMember
67+
seqno: 184
68+
children: []
69+
- !ruby/struct:Net::IMAP::ThreadMember
70+
seqno: 185
71+
children: []
72+
- !ruby/struct:Net::IMAP::ThreadMember
73+
seqno: 186
74+
children: []
75+
- !ruby/struct:Net::IMAP::ThreadMember
76+
seqno: 187
77+
children: []
78+
- !ruby/struct:Net::IMAP::ThreadMember
79+
seqno: 189
80+
children: []
81+
- !ruby/struct:Net::IMAP::ThreadMember
82+
seqno: 190
83+
children: []
84+
- !ruby/struct:Net::IMAP::ThreadMember
85+
seqno: 191
86+
children: []
87+
- !ruby/struct:Net::IMAP::ThreadMember
88+
seqno: 192
89+
children: []
90+
- !ruby/struct:Net::IMAP::ThreadMember
91+
seqno: 193
92+
children: []
93+
- !ruby/struct:Net::IMAP::ThreadMember
94+
seqno: 194
95+
children:
96+
- !ruby/struct:Net::IMAP::ThreadMember
97+
seqno: 195
98+
children: []
99+
- !ruby/struct:Net::IMAP::ThreadMember
100+
seqno: 196
101+
children:
102+
- !ruby/struct:Net::IMAP::ThreadMember
103+
seqno: 197
104+
children: []
105+
- !ruby/struct:Net::IMAP::ThreadMember
106+
seqno: 198
107+
children: []
108+
- !ruby/struct:Net::IMAP::ThreadMember
109+
seqno: 199
110+
children: []
111+
- !ruby/struct:Net::IMAP::ThreadMember
112+
seqno: 200
113+
children:
114+
- !ruby/struct:Net::IMAP::ThreadMember
115+
seqno: 202
116+
children: []
117+
- !ruby/struct:Net::IMAP::ThreadMember
118+
seqno: 201
119+
children: []
120+
- !ruby/struct:Net::IMAP::ThreadMember
121+
seqno: 203
122+
children: []
123+
- !ruby/struct:Net::IMAP::ThreadMember
124+
seqno: 204
125+
children: []
126+
- !ruby/struct:Net::IMAP::ThreadMember
127+
seqno: 205
128+
children: []
129+
- !ruby/struct:Net::IMAP::ThreadMember
130+
seqno: 206
131+
children:
132+
- !ruby/struct:Net::IMAP::ThreadMember
133+
seqno: 207
134+
children: []
135+
- !ruby/struct:Net::IMAP::ThreadMember
136+
seqno: 208
137+
children: []
138+
raw_data: "* THREAD (166)(167)(168)(169)(172)(170)(171)(173)(174 (175)(176)(178)(181)(180))(179)(177(183)(182)(188)(184)(185)(186)(187)(189))(190)(191)(192)(193)(194
139+
195)(196 (197)(198))(199)(200 202)(201)(203)(204)(205)(206 207)(208)\r\n"
140+
thread_rfc5256_example2:
141+
:response: "* THREAD (166)(167)(168)(169)(172)((170)(179))(171)(173)((174)(175)(176)(178)(181)(180))((177)(183)(182)(188
142+
(184)(189))(185 186)(187))(190)(191)(192)(193)((194)(195 196))(197 198)(199)(200
143+
202)(201)(203)(204)(205 206 207)(208)\r\n"
144+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
145+
name: THREAD
146+
data:
147+
- !ruby/struct:Net::IMAP::ThreadMember
148+
seqno: 166
149+
children: []
150+
- !ruby/struct:Net::IMAP::ThreadMember
151+
seqno: 167
152+
children: []
153+
- !ruby/struct:Net::IMAP::ThreadMember
154+
seqno: 168
155+
children: []
156+
- !ruby/struct:Net::IMAP::ThreadMember
157+
seqno: 169
158+
children: []
159+
- !ruby/struct:Net::IMAP::ThreadMember
160+
seqno: 172
161+
children: []
162+
- !ruby/struct:Net::IMAP::ThreadMember
163+
seqno:
164+
children:
165+
- !ruby/struct:Net::IMAP::ThreadMember
166+
seqno: 170
167+
children: []
168+
- !ruby/struct:Net::IMAP::ThreadMember
169+
seqno: 179
170+
children: []
171+
- !ruby/struct:Net::IMAP::ThreadMember
172+
seqno: 171
173+
children: []
174+
- !ruby/struct:Net::IMAP::ThreadMember
175+
seqno: 173
176+
children: []
177+
- !ruby/struct:Net::IMAP::ThreadMember
178+
seqno:
179+
children:
180+
- !ruby/struct:Net::IMAP::ThreadMember
181+
seqno: 174
182+
children: []
183+
- !ruby/struct:Net::IMAP::ThreadMember
184+
seqno: 175
185+
children: []
186+
- !ruby/struct:Net::IMAP::ThreadMember
187+
seqno: 176
188+
children: []
189+
- !ruby/struct:Net::IMAP::ThreadMember
190+
seqno: 178
191+
children: []
192+
- !ruby/struct:Net::IMAP::ThreadMember
193+
seqno: 181
194+
children: []
195+
- !ruby/struct:Net::IMAP::ThreadMember
196+
seqno: 180
197+
children: []
198+
- !ruby/struct:Net::IMAP::ThreadMember
199+
seqno:
200+
children:
201+
- !ruby/struct:Net::IMAP::ThreadMember
202+
seqno: 177
203+
children: []
204+
- !ruby/struct:Net::IMAP::ThreadMember
205+
seqno: 183
206+
children: []
207+
- !ruby/struct:Net::IMAP::ThreadMember
208+
seqno: 182
209+
children: []
210+
- !ruby/struct:Net::IMAP::ThreadMember
211+
seqno: 188
212+
children:
213+
- !ruby/struct:Net::IMAP::ThreadMember
214+
seqno: 184
215+
children: []
216+
- !ruby/struct:Net::IMAP::ThreadMember
217+
seqno: 189
218+
children: []
219+
- !ruby/struct:Net::IMAP::ThreadMember
220+
seqno: 185
221+
children:
222+
- !ruby/struct:Net::IMAP::ThreadMember
223+
seqno: 186
224+
children: []
225+
- !ruby/struct:Net::IMAP::ThreadMember
226+
seqno: 187
227+
children: []
228+
- !ruby/struct:Net::IMAP::ThreadMember
229+
seqno: 190
230+
children: []
231+
- !ruby/struct:Net::IMAP::ThreadMember
232+
seqno: 191
233+
children: []
234+
- !ruby/struct:Net::IMAP::ThreadMember
235+
seqno: 192
236+
children: []
237+
- !ruby/struct:Net::IMAP::ThreadMember
238+
seqno: 193
239+
children: []
240+
- !ruby/struct:Net::IMAP::ThreadMember
241+
seqno:
242+
children:
243+
- !ruby/struct:Net::IMAP::ThreadMember
244+
seqno: 194
245+
children: []
246+
- !ruby/struct:Net::IMAP::ThreadMember
247+
seqno: 195
248+
children:
249+
- !ruby/struct:Net::IMAP::ThreadMember
250+
seqno: 196
251+
children: []
252+
- !ruby/struct:Net::IMAP::ThreadMember
253+
seqno: 197
254+
children:
255+
- !ruby/struct:Net::IMAP::ThreadMember
256+
seqno: 198
257+
children: []
258+
- !ruby/struct:Net::IMAP::ThreadMember
259+
seqno: 199
260+
children: []
261+
- !ruby/struct:Net::IMAP::ThreadMember
262+
seqno: 200
263+
children:
264+
- !ruby/struct:Net::IMAP::ThreadMember
265+
seqno: 202
266+
children: []
267+
- !ruby/struct:Net::IMAP::ThreadMember
268+
seqno: 201
269+
children: []
270+
- !ruby/struct:Net::IMAP::ThreadMember
271+
seqno: 203
272+
children: []
273+
- !ruby/struct:Net::IMAP::ThreadMember
274+
seqno: 204
275+
children: []
276+
- !ruby/struct:Net::IMAP::ThreadMember
277+
seqno: 205
278+
children:
279+
- !ruby/struct:Net::IMAP::ThreadMember
280+
seqno: 206
281+
children:
282+
- !ruby/struct:Net::IMAP::ThreadMember
283+
seqno: 207
284+
children: []
285+
- !ruby/struct:Net::IMAP::ThreadMember
286+
seqno: 208
287+
children: []
288+
raw_data: "* THREAD (166)(167)(168)(169)(172)((170)(179))(171)(173)((174)(175)(176)(178)(181)(180))((177)(183)(182)(188
289+
(184)(189))(185 186)(187))(190)(191)(192)(193)((194)(195 196))(197 198)(199)(200
290+
202)(201)(203)(204)(205 206 207)(208)\r\n"
291+
thread_rfc5256_example3:
292+
:response: "* THREAD\r\n"
293+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
294+
name: THREAD
295+
data: []
296+
raw_data: "* THREAD\r\n"
297+
test_invalid_thread_empty_response:
298+
:response: "* THREAD \r\n"
299+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
300+
name: THREAD
301+
data: []
302+
raw_data: "* THREAD \r\n"
303+
thread_rfc5256_example4:
304+
:response: "* THREAD (2)(3 6 (4 23)(44 7 96))\r\n"
305+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
306+
name: THREAD
307+
data:
308+
- !ruby/struct:Net::IMAP::ThreadMember
309+
seqno: 2
310+
children: []
311+
- !ruby/struct:Net::IMAP::ThreadMember
312+
seqno: 3
313+
children:
314+
- !ruby/struct:Net::IMAP::ThreadMember
315+
seqno: 6
316+
children:
317+
- !ruby/struct:Net::IMAP::ThreadMember
318+
seqno: 4
319+
children:
320+
- !ruby/struct:Net::IMAP::ThreadMember
321+
seqno: 23
322+
children: []
323+
- !ruby/struct:Net::IMAP::ThreadMember
324+
seqno: 44
325+
children:
326+
- !ruby/struct:Net::IMAP::ThreadMember
327+
seqno: 7
328+
children:
329+
- !ruby/struct:Net::IMAP::ThreadMember
330+
seqno: 96
331+
children: []
332+
raw_data: "* THREAD (2)(3 6 (4 23)(44 7 96))\r\n"
333+
thread_rfc5256_example5:
334+
:response: "* THREAD ((3)(5))\r\n"
335+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
336+
name: THREAD
337+
data:
338+
- !ruby/struct:Net::IMAP::ThreadMember
339+
seqno:
340+
children:
341+
- !ruby/struct:Net::IMAP::ThreadMember
342+
seqno: 3
343+
children: []
344+
- !ruby/struct:Net::IMAP::ThreadMember
345+
seqno: 5
346+
children: []
347+
raw_data: "* THREAD ((3)(5))\r\n"

test/net/imap/test_imap_response_parser.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ def teardown
4242
############################################################################
4343
# IMAP extensions, by RFC:
4444

45+
# RFC 5256: THREAD response
46+
generate_tests_from fixture_file: "thread_responses.yml"
47+
4548
############################################################################
4649
# More interesting tests about the behavior, either of the test or of the
4750
# response data, should still use normal tests, below

0 commit comments

Comments
 (0)