-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patching the setup of the on close callback instead
the previous patch allowed the callback to be called only once, whereas this one will be long-lived for the duration of the connection
- Loading branch information
1 parent
ec7b845
commit e273010
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
require "support/http_helpers" | ||
|
||
class Bug_1_1_1_Test < Minitest::Test | ||
include HTTPHelpers | ||
|
||
def test_conection_callbacks_fire_setup_once | ||
uri = build_uri("/get") | ||
|
||
connected = 0 | ||
|
||
HTTPX.on_connection_opened { |*| connected += 1 } | ||
.on_connection_closed { |*| connected -= 1 } | ||
.wrap do |session| | ||
3.times.each do | ||
response = session.get(uri) | ||
verify_status(response, 200) | ||
assert connected.zero? | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def scheme | ||
"http://" | ||
end | ||
end |