2011-08-21 12:38:51 +00:00
|
|
|
package client
|
|
|
|
|
2011-08-23 09:49:22 +00:00
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
)
|
2011-08-21 12:38:51 +00:00
|
|
|
|
|
|
|
func setUp(t *testing.T) (*mockNetConn, *Conn) {
|
|
|
|
c := New("test", "test", "Testing IRC")
|
|
|
|
m := MockNetConn(t)
|
|
|
|
c.sock = m
|
|
|
|
c.Flood = true // Tests can take a while otherwise
|
|
|
|
c.postConnect()
|
|
|
|
return m, c
|
|
|
|
}
|
2011-08-22 22:23:29 +00:00
|
|
|
|
|
|
|
// Mock dispatcher to verify that events are triggered successfully
|
|
|
|
type mockDispatcher func(string, ...interface{})
|
|
|
|
|
|
|
|
func (d mockDispatcher) Dispatch(name string, ev ...interface{}) {
|
|
|
|
d(name, ev...)
|
|
|
|
}
|
2011-08-23 09:49:22 +00:00
|
|
|
|
|
|
|
func WasEventDispatched(name string, flag *bool) mockDispatcher {
|
|
|
|
return mockDispatcher(func(n string, ev ...interface{}) {
|
|
|
|
if n == strings.ToLower(name) {
|
|
|
|
*flag = true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|