mirror of
https://github.com/fluffle/goirc
synced 2025-07-02 11:33:54 +00:00
Remove embedded logger from state tracker. Hmmmm.
This commit is contained in:
parent
f4b53dfb24
commit
ca46884c72
6 changed files with 83 additions and 234 deletions
|
@ -5,12 +5,9 @@ import (
|
|||
)
|
||||
|
||||
func TestNewNick(t *testing.T) {
|
||||
_, s := setUp(t)
|
||||
defer s.tearDown()
|
||||
nk := NewNick("test1")
|
||||
|
||||
nk := NewNick("test1", s.log)
|
||||
|
||||
if nk.Nick != "test1" || nk.l != s.log {
|
||||
if nk.Nick != "test1" {
|
||||
t.Errorf("Nick not created correctly by NewNick()")
|
||||
}
|
||||
if len(nk.chans) != 0 || len(nk.lookup) != 0 {
|
||||
|
@ -19,11 +16,8 @@ func TestNewNick(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAddChannel(t *testing.T) {
|
||||
_, s := setUp(t)
|
||||
defer s.tearDown()
|
||||
|
||||
nk := NewNick("test1", s.log)
|
||||
ch := NewChannel("#test1", s.log)
|
||||
nk := NewNick("test1")
|
||||
ch := NewChannel("#test1")
|
||||
cp := new(ChanPrivs)
|
||||
|
||||
nk.addChannel(ch, cp)
|
||||
|
@ -37,24 +31,13 @@ func TestAddChannel(t *testing.T) {
|
|||
if c, ok := nk.lookup["#test1"]; !ok || c != ch {
|
||||
t.Errorf("Channel #test1 not properly stored in lookup map.")
|
||||
}
|
||||
|
||||
s.log.EXPECT().Warn("Nick.addChannel(): %s already on %s.",
|
||||
"test1", "#test1")
|
||||
nk.addChannel(ch, cp)
|
||||
}
|
||||
|
||||
func TestDelChannel(t *testing.T) {
|
||||
_, s := setUp(t)
|
||||
defer s.tearDown()
|
||||
|
||||
nk := NewNick("test1", s.log)
|
||||
ch := NewChannel("#test1", s.log)
|
||||
nk := NewNick("test1")
|
||||
ch := NewChannel("#test1")
|
||||
cp := new(ChanPrivs)
|
||||
|
||||
// Testing the error state first is easier
|
||||
s.log.EXPECT().Warn("Nick.delChannel(): %s not on %s.", "test1", "#test1")
|
||||
nk.delChannel(ch)
|
||||
|
||||
nk.addChannel(ch, cp)
|
||||
nk.delChannel(ch)
|
||||
if len(nk.chans) != 0 || len(nk.lookup) != 0 {
|
||||
|
@ -69,10 +52,7 @@ func TestDelChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestNickParseModes(t *testing.T) {
|
||||
_, s := setUp(t)
|
||||
defer s.tearDown()
|
||||
|
||||
nk := NewNick("test1", s.log)
|
||||
nk := NewNick("test1")
|
||||
md := nk.Modes
|
||||
|
||||
// Modes should all be false for a new nick
|
||||
|
@ -90,17 +70,4 @@ func TestNickParseModes(t *testing.T) {
|
|||
if !md.Invisible || md.Oper || !md.WallOps || md.HiddenHost || !md.SSL {
|
||||
t.Errorf("Modes not flipped correctly by ParseModes.")
|
||||
}
|
||||
|
||||
// Check that passing an unknown mode char results in an info log
|
||||
// The cast to byte here is needed to pass; gomock uses reflect.DeepEqual
|
||||
// to examine argument equality, but 'd' (when not implicitly coerced to a
|
||||
// uint8 by the type system) is an int, whereas string("+d")[1] is not.
|
||||
// This type difference (despite the values being nominally the same)
|
||||
// causes the test to fail with the following confusing error.
|
||||
//
|
||||
// no matching expected call: *logging.MockLogger.Info([Nick.ParseModes(): unknown mode char %c [100]])
|
||||
// missing call(s) to *logging.MockLogger.Info(is equal to Nick.ParseModes(): unknown mode char %c, is equal to [100])
|
||||
|
||||
s.log.EXPECT().Info("Nick.ParseModes(): unknown mode char %c", byte('d'))
|
||||
nk.ParseModes("+d")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue