1
0
Fork 0
mirror of https://github.com/fluffle/goirc synced 2025-07-02 11:33:54 +00:00

Moar testing and updates.

This commit is contained in:
Alex Bramley 2011-10-22 23:58:06 +01:00
parent 1fbd0a8b17
commit 6ded98b9e5
2 changed files with 141 additions and 28 deletions

38
state/nick_test.go Normal file
View file

@ -0,0 +1,38 @@
package state
import (
"github.com/fluffle/goirc/logging"
"testing"
)
func TestNewNick(t *testing.T) {
l, _ := logging.NewMock()
nk := NewNick("test1", l)
if nk.Nick != "test1" || nk.l != l {
t.Errorf("Nick not created correctly by NewNick()")
}
if len(nk.chans) != 0 || len(nk.lookup) != 0 {
t.Errorf("Nick maps contain data after NewNick()")
}
}
func TestAddChannel(t *testing.T) {
l, m := logging.NewMock()
nk := NewNick("test1", l)
ch := NewChannel("#test1", l)
cp := new(ChanPrivs)
nk.addChannel(ch, cp)
m.CheckNothingWritten(t)
if len(nk.chans) != 1 || len(nk.lookup) != 1 {
t.Errorf("Channel lists not updated correctly.")
}
if c, ok := nk.chans[ch]; !ok || c != cp {
t.Errorf("Channel #test1 not properly stored in chans map.")
}
if c, ok := nk.lookup["#test1"]; !ok || c != ch {
t.Errorf("Channel #test1 not properly stored in lookup map.")
}
}