Skip to content

Commit

Permalink
#14 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 10, 2024
1 parent 86044e0 commit b361fe4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/test_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

require 'minitest/autorun'
require 'threads'
require 'socket'
require_relative '../lib/random-port/pool'

# Pool test.
Expand All @@ -34,7 +35,7 @@ class RandomPort::TestPool < Minitest::Test
def test_acquires_and_releases
pool = RandomPort::Pool.new
port = pool.acquire
server = TCPServer.new(port)
server = TCPServer.new('localhost', port)
server.close
assert(!port.nil?)
assert(port.positive?)
Expand All @@ -46,7 +47,7 @@ def test_acquires_and_releases_three_ports
assert_equal(0, pool.size)
ports = pool.acquire(3, timeout: 16)
ports.each do |p|
server = TCPServer.new(p)
server = TCPServer.new('localhost', p)
server.close
end
assert_equal(3, pool.size)
Expand All @@ -63,7 +64,7 @@ def test_acquires_and_releases_three_ports_in_block
assert_equal(3, ports.count)
assert_equal(3, pool.size)
ports.each do |p|
server = TCPServer.new(p)
server = TCPServer.new('localhost', p)
server.close
end
end
Expand All @@ -84,7 +85,7 @@ def test_acquires_and_releases_in_threads
Threads.new(100).assert do
pool.acquire(5) do |ports|
ports.each do |p|
server = TCPServer.new(p)
server = TCPServer.new('localhost', p)
server.close
end
end
Expand Down

0 comments on commit b361fe4

Please sign in to comment.