Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Return empty SearchResult for no search result #362

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/net/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3155,7 +3155,13 @@ def search_internal(cmd, keys, charset = nil)
args = charset ? ["CHARSET", charset, *keys] : keys
synchronize do
send_command(cmd, *args)
clear_responses("SEARCH").last || []
search_result = clear_responses("SEARCH").last
if search_result
search_result
else
# warn NO_SEARCH_RESPONSE
SearchResult[]
end
end
end

Expand Down
6 changes: 4 additions & 2 deletions test/net/imap/test_imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1264,9 +1264,11 @@ def seqset_coercible.to_sequence_set
server.on "SEARCH", &:done_ok
server.on "UID SEARCH", &:done_ok
found = imap.search ["subject", "hello"]
assert_equal [], found
assert_instance_of Net::IMAP::SearchResult, found
assert_empty found
found = imap.uid_search ["subject", "hello"]
assert_equal [], found
assert_instance_of Net::IMAP::SearchResult, found
assert_empty found
end
end

Expand Down
Loading