diff options
Diffstat (limited to 'test/rubygems/test_gem_request_connection_pools.rb')
-rw-r--r-- | test/rubygems/test_gem_request_connection_pools.rb | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/test/rubygems/test_gem_request_connection_pools.rb b/test/rubygems/test_gem_request_connection_pools.rb index c5e7cf2ed4..966447bff6 100644 --- a/test/rubygems/test_gem_request_connection_pools.rb +++ b/test/rubygems/test_gem_request_connection_pools.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/request' -require 'timeout' + +require_relative "helper" +require "rubygems/request" +require "rubygems/vendored_timeout" class TestGemRequestConnectionPool < Gem::TestCase class FakeHttp @@ -17,7 +18,7 @@ class TestGemRequestConnectionPool < Gem::TestCase @old_client = Gem::Request::ConnectionPools.client Gem::Request::ConnectionPools.client = FakeHttp - @proxy = URI 'http://proxy.example' + @proxy = Gem::URI "http://proxy.example" end def teardown @@ -32,9 +33,9 @@ class TestGemRequestConnectionPool < Gem::TestCase ems.example ] - no_proxy = pools.send :no_proxy?, 'rubygems.example', env_no_proxy + no_proxy = pools.send :no_proxy?, "rubygems.example", env_no_proxy - refute no_proxy, 'mismatch' + refute no_proxy, "mismatch" end def test_to_proxy_empty_string @@ -42,13 +43,13 @@ class TestGemRequestConnectionPool < Gem::TestCase env_no_proxy = [""] - no_proxy = pools.send :no_proxy?, 'ems.example', env_no_proxy + no_proxy = pools.send :no_proxy?, "ems.example", env_no_proxy - refute no_proxy, 'mismatch' + refute no_proxy, "mismatch" end def test_checkout_same_connection - uri = URI.parse('http://example/some_endpoint') + uri = Gem::URI.parse("http://example/some_endpoint") pools = Gem::Request::ConnectionPools.new nil, [] pool = pools.pool_for uri @@ -66,13 +67,13 @@ class TestGemRequestConnectionPool < Gem::TestCase 2.no-proxy.example ] - no_proxy = pools.send :no_proxy?, '2.no-proxy.example', env_no_proxy + no_proxy = pools.send :no_proxy?, "2.no-proxy.example", env_no_proxy - assert no_proxy, 'match' + assert no_proxy, "match" - no_proxy = pools.send :no_proxy?, 'proxy.example', env_no_proxy + no_proxy = pools.send :no_proxy?, "proxy.example", env_no_proxy - refute no_proxy, 'mismatch' + refute no_proxy, "mismatch" end def test_to_proxy_eh_wildcard @@ -82,31 +83,31 @@ class TestGemRequestConnectionPool < Gem::TestCase .no-proxy.example ] - no_proxy = pools.send :no_proxy?, '2.no-proxy.example', env_no_proxy + no_proxy = pools.send :no_proxy?, "2.no-proxy.example", env_no_proxy - assert no_proxy, 'wildcard matching subdomain' + assert no_proxy, "wildcard matching subdomain" - no_proxy = pools.send :no_proxy?, 'no-proxy.example', env_no_proxy + no_proxy = pools.send :no_proxy?, "no-proxy.example", env_no_proxy - assert no_proxy, 'wildcard matching dotless domain' + assert no_proxy, "wildcard matching dotless domain" - no_proxy = pools.send :no_proxy?, 'proxy.example', env_no_proxy + no_proxy = pools.send :no_proxy?, "proxy.example", env_no_proxy - refute no_proxy, 'wildcard mismatch' + refute no_proxy, "wildcard mismatch" end def test_net_http_args pools = Gem::Request::ConnectionPools.new nil, [] - net_http_args = pools.send :net_http_args, URI('http://example'), nil + net_http_args = pools.send :net_http_args, Gem::URI("http://example"), nil - assert_equal ['example', 80], net_http_args + assert_equal ["example", 80], net_http_args end def test_net_http_args_ipv6 pools = Gem::Request::ConnectionPools.new nil, [] - net_http_args = pools.send :net_http_args, URI('http://[::1]'), nil + net_http_args = pools.send :net_http_args, Gem::URI("http://[::1]"), nil assert_equal ["::1", 80], net_http_args end @@ -114,34 +115,34 @@ class TestGemRequestConnectionPool < Gem::TestCase def test_net_http_args_proxy pools = Gem::Request::ConnectionPools.new nil, [] - net_http_args = pools.send :net_http_args, URI('http://example'), @proxy + net_http_args = pools.send :net_http_args, Gem::URI("http://example"), @proxy - assert_equal ['example', 80, 'proxy.example', 80, nil, nil], net_http_args + assert_equal ["example", 80, "proxy.example", 80, nil, nil], net_http_args end def test_net_http_args_no_proxy - orig_no_proxy, ENV['no_proxy'] = ENV['no_proxy'], 'example' + orig_no_proxy = ENV["no_proxy"] + ENV["no_proxy"] = "example" pools = Gem::Request::ConnectionPools.new nil, [] - net_http_args = pools.send :net_http_args, URI('http://example'), @proxy - - assert_equal ['example', 80, nil, nil], net_http_args + net_http_args = pools.send :net_http_args, Gem::URI("http://example"), @proxy + assert_equal ["example", 80, nil, nil], net_http_args ensure - ENV['no_proxy'] = orig_no_proxy + ENV["no_proxy"] = orig_no_proxy end def test_thread_waits_for_connection - uri = URI.parse('http://example/some_endpoint') + uri = Gem::URI.parse("http://example/some_endpoint") pools = Gem::Request::ConnectionPools.new nil, [] pool = pools.pool_for uri pool.checkout Thread.new do - assert_raise(Timeout::Error) do - Timeout.timeout(1) do + assert_raise(Gem::Timeout::Error) do + Gem::Timeout.timeout(1) do pool.checkout end end |