Skip to content

Commit

Permalink
test_binder.rb
Browse files Browse the repository at this point in the history
Add two tests for using both tcp & unix listeners
  • Loading branch information
MSP-Greg committed Sep 24, 2019
1 parent d50a971 commit 9ad8399
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/test_binder.rb
Expand Up @@ -50,6 +50,46 @@ def test_logs_all_localhost_bindings
assert_match %r!tcp://\[::1\]:(\d+)!, @events.stdout.string
end
end

def test_allows_both_unix_and_tcp
skip UNIX_SKT_MSG unless UNIX_SKT_EXIST

path_unix = "test/#{name}_server.sock"
uri_unix = "unix://#{path_unix}"
uri_tcp = "tcp://127.0.0.1:#{UniquePort.call}"

@binder.parse([uri_unix, uri_tcp], @events)

stdout = @events.stdout.string

assert stdout.include?(uri_unix), "\n#{stdout}\n"
assert stdout.include?(uri_tcp) , "\n#{stdout}\n"

ensure
return if skipped?
@binder.close
File.unlink(path_unix) if File.exist? path_unix
end

def test_allows_both_tcp_and_unix
skip UNIX_SKT_MSG unless UNIX_SKT_EXIST

path_unix = "test/#{name}_server.sock"
uri_unix = "unix://#{path_unix}"
uri_tcp = "tcp://127.0.0.1:#{UniquePort.call}"

@binder.parse([uri_tcp, uri_unix], @events)

stdout = @events.stdout.string

assert stdout.include?(uri_unix), "\n#{stdout}\n"
assert stdout.include?(uri_tcp) , "\n#{stdout}\n"

ensure
return if skipped?
@binder.close
File.unlink(path_unix) if File.exist? path_unix
end
end

class TestBinderJRuby < TestBinderBase
Expand Down

0 comments on commit 9ad8399

Please sign in to comment.