mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-11-29 00:01:06 -05:00
using session pool for coalescing test, thereby minimizing interference (although it would have been nice to have more entropy)
This commit is contained in:
parent
cdf6868059
commit
a6176ec01f
@ -31,15 +31,15 @@ class HTTPSTest < Minitest::Test
|
||||
|
||||
def test_connection_coalescing
|
||||
coalesced_origin = "https://#{ENV["HTTPBIN_COALESCING_HOST"]}"
|
||||
HTTPX.wrap do |http|
|
||||
HTTPX.plugin(SessionWithPool).wrap do |http|
|
||||
response1 = http.get(origin)
|
||||
verify_status(response1, 200)
|
||||
response2 = http.get(coalesced_origin)
|
||||
verify_status(response2, 200)
|
||||
# introspection time
|
||||
pool = http.__send__(:pool)
|
||||
connections = pool.instance_variable_get(:@connections)
|
||||
origins = connections.map { |conn| conn.instance_variable_get(:@origins) }
|
||||
pool = http.pool
|
||||
connections = pool.connections
|
||||
origins = connections.map(&:origins)
|
||||
assert origins.any? { |orgs| orgs.sort == [origin, coalesced_origin].sort },
|
||||
"connections for #{[origin, coalesced_origin]} didn't coalesce (expected connection with both origins (#{origins}))"
|
||||
end
|
||||
|
||||
@ -35,6 +35,8 @@ module SessionWithPool
|
||||
end
|
||||
|
||||
module ConnectionMethods
|
||||
attr_reader :origins
|
||||
|
||||
def set_parser_callbacks(parser)
|
||||
super
|
||||
parser.on(:pong) { emit(:pong) }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user