From 9ad8399204ed3a8cfc2ee5717811a2fcc53deb5d Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Tue, 24 Sep 2019 10:48:20 -0500 Subject: [PATCH] test_binder.rb Add two tests for using both tcp & unix listeners --- test/test_binder.rb | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/test/test_binder.rb b/test/test_binder.rb index b5ab9aa575..8fb8af9975 100644 --- a/test/test_binder.rb +++ b/test/test_binder.rb @@ -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