mirror of https://github.com/tidwall/redcon.git
unix socket tests
This commit is contained in:
parent
89a9dbebb2
commit
0dba69d996
|
@ -212,8 +212,9 @@ func TestServerTCP(t *testing.T) {
|
||||||
testServerNetwork(t, "tcp", ":12345")
|
testServerNetwork(t, "tcp", ":12345")
|
||||||
}
|
}
|
||||||
func TestServerUnix(t *testing.T) {
|
func TestServerUnix(t *testing.T) {
|
||||||
defer os.RemoveAll("unix.net")
|
os.RemoveAll("/tmp/redcon-unix.sock")
|
||||||
testServerNetwork(t, "unix", "unix.net")
|
defer os.RemoveAll("/tmp/redcon-unix.sock")
|
||||||
|
testServerNetwork(t, "unix", "/tmp/redcon-unix.sock")
|
||||||
}
|
}
|
||||||
|
|
||||||
func testServerNetwork(t *testing.T, network, laddr string) {
|
func testServerNetwork(t *testing.T, network, laddr string) {
|
||||||
|
@ -257,10 +258,6 @@ func testServerNetwork(t *testing.T, network, laddr string) {
|
||||||
t.Fatalf("expected an error, should not be able to close before serving")
|
t.Fatalf("expected an error, should not be able to close before serving")
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
|
|
||||||
if network == "unix" {
|
|
||||||
os.RemoveAll(laddr)
|
|
||||||
}
|
|
||||||
time.Sleep(time.Second / 4)
|
time.Sleep(time.Second / 4)
|
||||||
if err := ListenAndServeNetwork(network, laddr, func(conn Conn, cmd Command) {}, nil, nil); err == nil {
|
if err := ListenAndServeNetwork(network, laddr, func(conn Conn, cmd Command) {}, nil, nil); err == nil {
|
||||||
t.Fatalf("expected an error, should not be able to listen on the same port")
|
t.Fatalf("expected an error, should not be able to listen on the same port")
|
||||||
|
|
Loading…
Reference in New Issue