From a6176ec01ff424c4a80ffa3aae6fb11d45322b6c Mon Sep 17 00:00:00 2001 From: HoneyryderChuck Date: Tue, 5 Jan 2021 10:36:14 +0000 Subject: [PATCH] using session pool for coalescing test, thereby minimizing interference (although it would have been nice to have more entropy) --- test/https_test.rb | 8 ++++---- test/support/session_with_pool.rb | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/https_test.rb b/test/https_test.rb index 1d6193ee..2b5a7dcf 100644 --- a/test/https_test.rb +++ b/test/https_test.rb @@ -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 diff --git a/test/support/session_with_pool.rb b/test/support/session_with_pool.rb index 6899ed68..37e763e8 100644 --- a/test/support/session_with_pool.rb +++ b/test/support/session_with_pool.rb @@ -35,6 +35,8 @@ module SessionWithPool end module ConnectionMethods + attr_reader :origins + def set_parser_callbacks(parser) super parser.on(:pong) { emit(:pong) }