Remove RunLocalUDPServerUnsafe test method (#777)

Instead of having a separate RunLocalUDPServerUnsafe, we can use the
functional options added to RunLocalUDPServerWithFinChan in ab16005053.
This commit is contained in:
Tom Thorogood 2018-10-10 04:11:23 +10:30 committed by Miek Gieben
parent c0283a2028
commit ac339476d7
1 changed files with 2 additions and 22 deletions

View File

@ -88,27 +88,6 @@ func RunLocalUDPServerWithFinChan(laddr string, opts ...func(*Server)) (*Server,
return server, pc.LocalAddr().String(), fin, nil
}
func RunLocalUDPServerUnsafe(laddr string) (*Server, string, error) {
pc, err := net.ListenPacket("udp", laddr)
if err != nil {
return nil, "", err
}
server := &Server{PacketConn: pc, Unsafe: true,
ReadTimeout: time.Hour, WriteTimeout: time.Hour}
waitLock := sync.Mutex{}
waitLock.Lock()
server.NotifyStartedFunc = waitLock.Unlock
go func() {
server.ActivateAndServe()
pc.Close()
}()
waitLock.Lock()
return server, pc.LocalAddr().String(), nil
}
func RunLocalTCPServer(laddr string) (*Server, string, error) {
server, l, _, err := RunLocalTCPServerWithFinChan(laddr)
@ -604,7 +583,8 @@ func TestServingResponse(t *testing.T) {
}
s.Shutdown()
s, addrstr, err = RunLocalUDPServerUnsafe(":0")
s, addrstr, _, err = RunLocalUDPServerWithFinChan(":0",
func(srv *Server) { srv.Unsafe = true })
if err != nil {
t.Fatalf("unable to run test server: %v", err)
}