mirror of
https://github.com/fluffle/goirc
synced 2025-05-14 11:33:20 +00:00
Move some basic assertions about initial state into setUp().
This commit is contained in:
parent
389f5247f5
commit
cf8ab830f7
2 changed files with 22 additions and 22 deletions
|
@ -10,10 +10,31 @@ func setUp(t *testing.T) (*mockNetConn, *Conn) {
|
|||
c := New("test", "test", "Testing IRC")
|
||||
c.State = t
|
||||
|
||||
// Assert some basic things about the initial state of the Conn struct
|
||||
if c.Me.Nick != "test" ||
|
||||
c.Me.Ident != "test" ||
|
||||
c.Me.Name != "Testing IRC" ||
|
||||
c.Me.Host != "" {
|
||||
t.Errorf("Conn.Me not correctly initialised.")
|
||||
}
|
||||
if len(c.chans) != 0 {
|
||||
t.Errorf("Some channels are already known:")
|
||||
for _, ch := range c.chans {
|
||||
t.Logf(ch.String())
|
||||
}
|
||||
}
|
||||
if len(c.nicks) != 1 {
|
||||
t.Errorf("Other Nicks than ourselves exist:")
|
||||
for _, n := range c.nicks {
|
||||
t.Logf(n.String())
|
||||
}
|
||||
}
|
||||
|
||||
m := MockNetConn(t)
|
||||
c.sock = m
|
||||
c.Flood = true // Tests can take a while otherwise
|
||||
c.postConnect()
|
||||
c.Flood = true // Tests can take a while otherwise
|
||||
c.Connected = true
|
||||
return m, c
|
||||
}
|
||||
|
||||
|
@ -50,9 +71,6 @@ func (conn *Conn) ExpectNoErrors() {
|
|||
func TestShutdown(t *testing.T) {
|
||||
_, c := setUp(t)
|
||||
|
||||
// Shutdown won't clean things up unless we're "connected" already
|
||||
c.Connected = true
|
||||
|
||||
// Setup a mock event dispatcher to test correct triggering of "disconnected"
|
||||
flag := false
|
||||
c.Dispatcher = WasEventDispatched("disconnected", &flag)
|
||||
|
@ -91,9 +109,6 @@ func TestShutdown(t *testing.T) {
|
|||
func TestEOF(t *testing.T) {
|
||||
m, c := setUp(t)
|
||||
|
||||
// Shutdown won't clean things up unless we're "connected" already
|
||||
c.Connected = true
|
||||
|
||||
// Setup a mock event dispatcher to test correct triggering of "disconnected"
|
||||
flag := false
|
||||
c.Dispatcher = WasEventDispatched("disconnected", &flag)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue