mirror of
https://github.com/fluffle/goirc
synced 2025-05-14 03:23:21 +00:00
Use call checker instead of writing to shared var in tests (10->1).
This commit is contained in:
parent
637cdb573f
commit
4eaad0e95e
2 changed files with 63 additions and 85 deletions
|
@ -186,18 +186,15 @@ func TestPanicRecovery(t *testing.T) {
|
|||
c, s := setUp(t)
|
||||
defer s.tearDown()
|
||||
|
||||
recovered := false
|
||||
recovered := callCheck(t)
|
||||
c.cfg.Recover = func(conn *Conn, line *Line) {
|
||||
if err, ok := recover().(string); ok && err == "panic!" {
|
||||
recovered = true
|
||||
recovered.call()
|
||||
}
|
||||
}
|
||||
c.HandleFunc(PRIVMSG, func(conn *Conn, line *Line) {
|
||||
panic("panic!")
|
||||
})
|
||||
c.in <- parseLine(":nick!user@host.com PRIVMSG #channel :OH NO PIGEONS")
|
||||
<-time.After(time.Millisecond)
|
||||
if recovered != true {
|
||||
t.Errorf("Failed to recover panic!")
|
||||
}
|
||||
recovered.assertWasCalled("Failed to recover panic!")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue