Exemplo n.º 1
0
func setUp(t *testing.T, start ...bool) (*Conn, *testState) {
	ctrl := gomock.NewController(t)
	st := state.NewMockStateTracker(ctrl)
	r := event.NewRegistry()
	ed := event.NewMockEventDispatcher(ctrl)
	nc := MockNetConn(t)
	c := Client("test", "test", "Testing IRC", r)
	logging.SetLogLevel(logging.LogFatal)

	c.ED = ed
	c.ST = st
	c.st = true
	c.sock = nc
	c.Flood = true // Tests can take a while otherwise
	c.Connected = true
	if len(start) == 0 {
		// Hack to allow tests of send, recv, write etc.
		// NOTE: the value of the boolean doesn't matter.
		c.postConnect()
		// Sleep 1ms to allow background routines to start.
		<-time.After(1e6)
	}

	return c, &testState{ctrl, st, ed, nc, c}
}
Exemplo n.º 2
0
// NOTE: including a second argument at all prevents calling c.postConnect()
func setUp(t *testing.T, start ...bool) (*Conn, *testState) {
	ctrl := gomock.NewController(t)
	st := state.NewMockTracker(ctrl)
	nc := MockNetConn(t)
	c := SimpleClient("test", "test", "Testing IRC")
	logging.SetLogLevel(logging.LogFatal)

	c.st = st
	c.sock = nc
	c.cfg.Flood = true // Tests can take a while otherwise
	c.connected = true
	// If a second argument is passed to setUp, we tell postConnect not to
	// start the various goroutines that shuttle data around.
	c.postConnect(len(start) == 0)
	// Sleep 1ms to allow background routines to start.
	<-time.After(1e6)

	return c, &testState{ctrl, st, nc, c}
}
Exemplo n.º 3
0
func init() {
	// This is probably a dirty hack...
	logging.InitFromFlags()
	logging.SetLogLevel(logging.LogFatal)
}