Coverage: Add silly little test to appease

This commit is contained in:
kayos@tcp.direct 2022-05-02 22:05:31 -07:00
parent af4ae39f57
commit 0dec6ca8e2
Signed by: kayos
GPG Key ID: 4B841471B4BEE979
2 changed files with 31 additions and 1 deletions

View File

@ -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) {

30
handler_test.go Normal file
View File

@ -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
}