-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix :127.0.0.1:1234 not working as specified in documentation fo…
…r admin connect string Fixes #395
- Loading branch information
Showing
3 changed files
with
130 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package admin | ||
|
||
import "testing" | ||
|
||
func TestAdminConnectAddressOnlyNoPort(t *testing.T) { | ||
connect := splitAdminConnectString("127.0.0.1") | ||
|
||
if connect[0] != "tcp" { | ||
t.Errorf("Expected connection type tcp, received: %s", connect[0]) | ||
} | ||
if connect[1] != "127.0.0.1" { | ||
t.Errorf("Expected connection address 127.0.0.1, received: %s", connect[1]) | ||
} | ||
} | ||
|
||
func TestAdminConnectAddressOnlyWithPort(t *testing.T) { | ||
connect := splitAdminConnectString("127.0.0.1:1234") | ||
|
||
if connect[0] != "tcp" { | ||
t.Errorf("Expected connection type tcp, received: %s", connect[0]) | ||
} | ||
if connect[1] != "127.0.0.1:1234" { | ||
t.Errorf("Expected connection address 127.0.0.1:1234, received: %s", connect[1]) | ||
} | ||
} | ||
|
||
func TestAdminConnectAddressEmptyTransport(t *testing.T) { | ||
connect := splitAdminConnectString(":127.0.0.1:1234") | ||
|
||
if connect[0] != "tcp" { | ||
t.Errorf("Expected connection type tcp, received: %s", connect[0]) | ||
} | ||
if connect[1] != "127.0.0.1:1234" { | ||
t.Errorf("Expected connection address 127.0.0.1:1234, received: %s", connect[1]) | ||
} | ||
} | ||
|
||
func TestAdminConnectTcpNoPort(t *testing.T) { | ||
connect := splitAdminConnectString("tcp:127.0.0.1") | ||
|
||
if connect[0] != "tcp" { | ||
t.Errorf("Expected connection type tcp, received: %s", connect[0]) | ||
} | ||
if connect[1] != "127.0.0.1" { | ||
t.Errorf("Expected connection address 127.0.0.1, received: %s", connect[1]) | ||
} | ||
} | ||
|
||
func TestAdminConnectTcpWithPort(t *testing.T) { | ||
connect := splitAdminConnectString("tcp:127.0.0.1:1234") | ||
|
||
if connect[0] != "tcp" { | ||
t.Errorf("Expected connection type tcp, received: %s", connect[0]) | ||
} | ||
if connect[1] != "127.0.0.1:1234" { | ||
t.Errorf("Expected connection address 127.0.0.1:1234, received: %s", connect[1]) | ||
} | ||
} | ||
|
||
func TestAdminConnectTcp6NoPort(t *testing.T) { | ||
connect := splitAdminConnectString("tcp:[::1]") | ||
|
||
if connect[0] != "tcp" { | ||
t.Errorf("Expected connection type tcp, received: %s", connect[0]) | ||
} | ||
if connect[1] != "[::1]" { | ||
t.Errorf("Expected connection address [::1], received: %s", connect[1]) | ||
} | ||
} | ||
|
||
func TestAdminConnectTcp6WithPort(t *testing.T) { | ||
connect := splitAdminConnectString("tcp:[::1]:1234") | ||
|
||
if connect[0] != "tcp" { | ||
t.Errorf("Expected connection type tcp, received: %s", connect[0]) | ||
} | ||
if connect[1] != "[::1]:1234" { | ||
t.Errorf("Expected connection address [::1]:1234, received: %s", connect[1]) | ||
} | ||
} | ||
|
||
func TestAdminConnectUnix(t *testing.T) { | ||
connect := splitAdminConnectString("unix:/var/path/somewhere") | ||
|
||
if connect[0] != "unix" { | ||
t.Errorf("Expected connection type unix, received: %s", connect[0]) | ||
} | ||
if connect[1] != "/var/path/somewhere" { | ||
t.Errorf("Expected connection address /var/path/somewhere, received: %s", connect[1]) | ||
} | ||
} | ||
|
||
func TestAdminConnectUnixAlone(t *testing.T) { | ||
connect := splitAdminConnectString("unix") | ||
|
||
if connect[0] != "unix" { | ||
t.Errorf("Expected connection type unix, received: %s", connect[0]) | ||
} | ||
if connect[1] != "" { | ||
t.Errorf("Expected empty connection address, received: %s", connect[1]) | ||
} | ||
} | ||
|
||
func TestAdminConnectTcpAlone(t *testing.T) { | ||
connect := splitAdminConnectString("tcp") | ||
|
||
if connect[0] != "tcp" { | ||
t.Errorf("Expected connection type tcp, received: %s", connect[0]) | ||
} | ||
if connect[1] != "" { | ||
t.Errorf("Expected empty connection address, received: %s", connect[1]) | ||
} | ||
} |