Coverage: Add silly little test to appease
This commit is contained in:
parent
af4ae39f57
commit
0dec6ca8e2
|
@ -105,7 +105,7 @@ func (nest *nestedHandlers) lenFor(cmd string) (total int) {
|
|||
return 0
|
||||
}
|
||||
hndlrs := hs.(cmap.ConcurrentMap)
|
||||
return len(hndlrs.Keys())
|
||||
return hndlrs.Count()
|
||||
}
|
||||
|
||||
func (nest *nestedHandlers) getAllHandlersFor(s string) (handlers chan handlerTuple, ok bool) {
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package girc
|
||||
|
||||
import (
|
||||
"log"
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCaller_AddHandler(t *testing.T) {
|
||||
var passChan = make(chan struct{})
|
||||
nullClient := &Client{mu: sync.RWMutex{}}
|
||||
c := newCaller(nullClient, log.Default())
|
||||
c.AddBg("PRIVMSG", func(c *Client, e Event) {
|
||||
passChan <- struct{}{}
|
||||
})
|
||||
|
||||
go func() {
|
||||
c.exec("PRIVMSG", true, nullClient, &Event{})
|
||||
}()
|
||||
|
||||
if c.external.lenFor("JONES") != 0 {
|
||||
t.Fatalf("wanted %d handlers, got %d", 0, c.internal.lenFor("JONES"))
|
||||
}
|
||||
|
||||
if c.external.lenFor("PRIVMSG") != 1 {
|
||||
t.Fatalf("wanted %d handlers, got %d", 1, c.external.lenFor("PRIVMSG"))
|
||||
}
|
||||
|
||||
<-passChan
|
||||
}
|
Loading…
Reference in New Issue