Skip to content

Commit

Permalink
There's a possibility to have more than one status if it's an array
Browse files Browse the repository at this point in the history
  • Loading branch information
driv3r committed Oct 5, 2023
1 parent 13ea4d4 commit b89b70a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test/helpers/ghostferry_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,22 @@ def start_server

query = CGI::parse(req.body)

status = query["status"]
statuses = query["status"]
data = query["data"]

unless status
unless statuses
@server_last_error = ArgumentError.new("Ghostferry is improperly implemented and did not send a status")
resp.status = 400
@server.shutdown
end

status = status.first

@last_message_time = now
@status_handlers[status].each { |f| f.call(*data) } unless @status_handlers[status].nil?

statuses.each do |status|
next if @status_handlers[status].nil?

@status_handlers[status].each { |f| f.call(*data) }
end
rescue StandardError => e
# errors are not reported from WEBrick but the server should fail early
# as this indicates there is likely a programming error.
Expand Down

0 comments on commit b89b70a

Please sign in to comment.