delete unused connections from the multiplexer

This commit is contained in:
Jan Rüth 2019-01-08 10:43:20 +01:00 committed by Marten Seemann
parent 6fbe8d563e
commit 1a0aa50471
4 changed files with 37 additions and 1 deletions

View file

@ -45,6 +45,16 @@ var _ = Describe("Packet Handler Map", func() {
})
It("closes", func() {
getMultiplexer() // make the sync.Once execute
// replace the clientMuxer. getClientMultiplexer will now return the MockMultiplexer
mockMultiplexer := NewMockMultiplexer(mockCtrl)
origMultiplexer := connMuxer
connMuxer = mockMultiplexer
defer func() {
connMuxer = origMultiplexer
}()
testErr := errors.New("test error ")
sess1 := NewMockPacketHandler(mockCtrl)
sess1.EXPECT().destroy(testErr)
@ -52,6 +62,7 @@ var _ = Describe("Packet Handler Map", func() {
sess2.EXPECT().destroy(testErr)
handler.Add(protocol.ConnectionID{1, 1, 1, 1}, sess1)
handler.Add(protocol.ConnectionID{2, 2, 2, 2}, sess2)
mockMultiplexer.EXPECT().RemoveConn(gomock.Any())
handler.close(testErr)
})