server: allow to call server.Close() twice

This commit is contained in:
aler9
2021-05-09 14:10:21 +02:00
parent 1b9b19dd84
commit 994cd442e3
4 changed files with 38 additions and 22 deletions

View File

@@ -422,6 +422,17 @@ func TestServerHighLevelPublishRead(t *testing.T) {
}
}
func TestServerClose(t *testing.T) {
s := &Server{
Handler: &testServerHandler{},
}
err := s.Start("127.0.0.1:8554")
require.NoError(t, err)
s.Close()
s.Close()
}
func TestServerErrorWrongUDPPorts(t *testing.T) {
t.Run("non consecutive", func(t *testing.T) {
s := &Server{
@@ -449,6 +460,7 @@ func TestServerConnClose(t *testing.T) {
Handler: &testServerHandler{
onConnOpen: func(ctx *ServerHandlerOnConnOpenCtx) {
ctx.Conn.Close()
ctx.Conn.Close()
},
onConnClose: func(ctx *ServerHandlerOnConnCloseCtx) {
close(connClosed)
@@ -887,6 +899,7 @@ func TestServerSessionClose(t *testing.T) {
Handler: &testServerHandler{
onSessionOpen: func(ctx *ServerHandlerOnSessionOpenCtx) {
ctx.Session.Close()
ctx.Session.Close()
},
onSessionClose: func(ctx *ServerHandlerOnSessionCloseCtx) {
close(sessionClosed)