Coverage: Add silly little test to appease

This commit is contained in:
kayos@tcp.direct 2022-05-02 22:05:31 -07:00
orang tua af4ae39f57
melakukan 0dec6ca8e2
Ditandai oleh: kayos
GPG Key ID: 4B841471B4BEE979
2 mengubah file dengan 31 tambahan dan 1 penghapusan

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