mirror of https://github.com/fluffle/goirc
More nick tests.
This commit is contained in:
parent
1c39dbecbb
commit
75112d67e2
|
@ -27,7 +27,7 @@ func TestAddChannel(t *testing.T) {
|
||||||
m.CheckNothingWritten(t)
|
m.CheckNothingWritten(t)
|
||||||
|
|
||||||
if len(nk.chans) != 1 || len(nk.lookup) != 1 {
|
if len(nk.chans) != 1 || len(nk.lookup) != 1 {
|
||||||
t.Errorf("Channel lists not updated correctly.")
|
t.Errorf("Channel lists not updated correctly for add.")
|
||||||
}
|
}
|
||||||
if c, ok := nk.chans[ch]; !ok || c != cp {
|
if c, ok := nk.chans[ch]; !ok || c != cp {
|
||||||
t.Errorf("Channel #test1 not properly stored in chans map.")
|
t.Errorf("Channel #test1 not properly stored in chans map.")
|
||||||
|
@ -35,4 +35,32 @@ func TestAddChannel(t *testing.T) {
|
||||||
if c, ok := nk.lookup["#test1"]; !ok || c != ch {
|
if c, ok := nk.lookup["#test1"]; !ok || c != ch {
|
||||||
t.Errorf("Channel #test1 not properly stored in lookup map.")
|
t.Errorf("Channel #test1 not properly stored in lookup map.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nk.addChannel(ch, cp)
|
||||||
|
m.CheckWrittenAtLevel(t, logging.Warn,
|
||||||
|
"Nick.addChannel(): test1 already on #test1.")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDelChannel(t *testing.T) {
|
||||||
|
l, m := logging.NewMock()
|
||||||
|
nk := NewNick("test1", l)
|
||||||
|
ch := NewChannel("#test1", l)
|
||||||
|
cp := new(ChanPrivs)
|
||||||
|
|
||||||
|
// Testing the error state first is easier
|
||||||
|
nk.delChannel(ch)
|
||||||
|
m.CheckWrittenAtLevel(t, logging.Warn,
|
||||||
|
"Nick.delChannel(): test1 not on #test1.")
|
||||||
|
|
||||||
|
nk.addChannel(ch, cp)
|
||||||
|
nk.delChannel(ch)
|
||||||
|
if len(nk.chans) != 0 || len(nk.lookup) != 0 {
|
||||||
|
t.Errorf("Channel lists not updated correctly for del.")
|
||||||
|
}
|
||||||
|
if c, ok := nk.chans[ch]; ok || c != nil {
|
||||||
|
t.Errorf("Channel #test1 not properly removed from chans map.")
|
||||||
|
}
|
||||||
|
if c, ok := nk.lookup["#test1"]; ok || c != nil {
|
||||||
|
t.Errorf("Channel #test1 not properly removed from lookup map.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue