Skip to content

Commit 4da36c6

Browse files
committed
♻️ Move ID response parser tests to yaml
1 parent 24c5639 commit 4da36c6

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
:tests:
3+
test_id_rfc2971_example_3.1_nil:
4+
:response: "* ID NIL\r\n"
5+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
6+
name: ID
7+
data:
8+
raw_data: "* ID NIL\r\n"
9+
test_id_rfc2971_example_3.2_cyrus:
10+
:response: "* ID (\"name\" \"Cyrus\" \"version\" \"1.5\" \"os\" \"sunos\" \"os-version\" \"5.5\" \"support-url\" \"mailto:[email protected]\")\r\n"
11+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
12+
name: ID
13+
data:
14+
name: Cyrus
15+
version: "1.5"
16+
os: sunos
17+
os-version: "5.5"
18+
support-url: "mailto:[email protected]"
19+
raw_data: "* ID (\"name\" \"Cyrus\" \"version\" \"1.5\" \"os\" \"sunos\" \"os-version\" \"5.5\" \"support-url\" \"mailto:[email protected]\")\r\n"
20+
test_id_gmail:
21+
:response: "* ID (\"name\" \"GImap\" \"vendor\" \"Google, Inc.\" \"support-url\"
22+
NIL)\r\n"
23+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
24+
name: ID
25+
data:
26+
name: GImap
27+
vendor: Google, Inc.
28+
support-url:
29+
raw_data: "* ID (\"name\" \"GImap\" \"vendor\" \"Google, Inc.\" \"support-url\"
30+
NIL)\r\n"

test/net/imap/test_imap_response_parser.rb

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

45+
# RFC 2971: ID response
46+
generate_tests_from fixture_file: "id_responses.yml"
47+
4548
# RFC 4315: UIDPLUS extension, APPENDUID and COPYUID response codes
4649
generate_tests_from fixture_file: "uidplus_extension.yml"
4750

@@ -146,18 +149,6 @@ def test_enable
146149
assert_equal("SMTPUTF8", response.data.first)
147150
end
148151

149-
def test_id
150-
parser = Net::IMAP::ResponseParser.new
151-
response = parser.parse("* ID NIL\r\n")
152-
assert_equal("ID", response.name)
153-
assert_equal(nil, response.data)
154-
response = parser.parse("* ID (\"name\" \"GImap\" \"vendor\" \"Google, Inc.\" \"support-url\" NIL)\r\n")
155-
assert_equal("ID", response.name)
156-
assert_equal("GImap", response.data["name"])
157-
assert_equal("Google, Inc.", response.data["vendor"])
158-
assert_equal(nil, response.data.fetch("support-url"))
159-
end
160-
161152
# [Bug #13649]
162153
def test_status
163154
parser = Net::IMAP::ResponseParser.new

0 commit comments

Comments
 (0)