From 33a318d17341fcaa95551710620540e00b0bb4b0 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Fri, 6 Dec 2019 11:45:50 -0700 Subject: Don't append port to unix sockets See https://caddy.community/t/caddy-v2-php-fpm-502-error/6571?u=matt --- listeners_test.go | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'listeners_test.go') diff --git a/listeners_test.go b/listeners_test.go index 076b365..25e1394 100644 --- a/listeners_test.go +++ b/listeners_test.go @@ -250,3 +250,52 @@ func TestParseNetworkAddress(t *testing.T) { } } } + +func TestJoinHostPort(t *testing.T) { + for i, tc := range []struct { + pa ParsedAddress + offset uint + expect string + }{ + { + pa: ParsedAddress{ + Network: "tcp", + Host: "localhost", + StartPort: 1234, + EndPort: 1234, + }, + expect: "localhost:1234", + }, + { + pa: ParsedAddress{ + Network: "tcp", + Host: "localhost", + StartPort: 1234, + EndPort: 1235, + }, + expect: "localhost:1234", + }, + { + pa: ParsedAddress{ + Network: "tcp", + Host: "localhost", + StartPort: 1234, + EndPort: 1235, + }, + offset: 1, + expect: "localhost:1235", + }, + { + pa: ParsedAddress{ + Network: "unix", + Host: "/run/php/php7.3-fpm.sock", + }, + expect: "/run/php/php7.3-fpm.sock", + }, + } { + actual := tc.pa.JoinHostPort(tc.offset) + if actual != tc.expect { + t.Errorf("Test %d: Expected '%s' but got '%s'", i, tc.expect, actual) + } + } +} -- cgit v1.2.3