1
0
Fork 0
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:
Alex Bramley 2013-09-30 14:43:29 +01:00
parent 637cdb573f
commit 4eaad0e95e
2 changed files with 63 additions and 85 deletions

View file

@ -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!")
}