Recover panics in irc.Client.recv()
This commit is contained in:
parent
f429a528ba
commit
cbbfda3e36
|
@ -146,6 +146,10 @@ func (c *Client) send() {
|
|||
}
|
||||
|
||||
func (c *Client) recv() {
|
||||
defer func() {
|
||||
recover()
|
||||
}()
|
||||
|
||||
c.sendRecv.Add(1)
|
||||
defer c.sendRecv.Done()
|
||||
|
||||
|
|
|
@ -132,6 +132,19 @@ func TestRecv(t *testing.T) {
|
|||
initTestClient()
|
||||
}
|
||||
|
||||
func TestRecvRecoversPanic(t *testing.T) {
|
||||
defer func() {
|
||||
assert.Nil(t, recover())
|
||||
}()
|
||||
|
||||
buf := bytes.NewBuffer([]byte("CMD\r\n"))
|
||||
c.reader = bufio.NewReader(buf)
|
||||
close(c.Messages)
|
||||
c.recv()
|
||||
|
||||
c.Messages = make(chan *Message, 32)
|
||||
}
|
||||
|
||||
/*func TestRecvTriggersReconnect(t *testing.T) {
|
||||
c.reader = bufio.NewReader(&bytes.Buffer{})
|
||||
c.ready.Add(1)
|
||||
|
|
Loading…
Reference in New Issue