From b4870bc685b052e145cb37cf06ab235820656ffa Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Wed, 1 Apr 2015 17:54:33 +0100 Subject: [PATCH] Tell state tracker all the information about Me. --- client/connection.go | 3 +-- client/connection_test.go | 10 +++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/client/connection.go b/client/connection.go index c577b51..ab4c4e3 100644 --- a/client/connection.go +++ b/client/connection.go @@ -187,9 +187,8 @@ func (conn *Conn) EnableStateTracking() { if conn.st == nil { n := conn.cfg.Me conn.st = state.NewTracker(n.Nick) + conn.st.NickInfo(n.Nick, n.Ident, n.Host, n.Name) conn.cfg.Me = conn.st.Me() - conn.cfg.Me.Ident = n.Ident - conn.cfg.Me.Name = n.Name conn.addSTHandlers() } } diff --git a/client/connection_test.go b/client/connection_test.go index 116f06f..15f03cd 100644 --- a/client/connection_test.go +++ b/client/connection_test.go @@ -104,7 +104,8 @@ func TestClientAndStateTracking(t *testing.T) { c := SimpleClient("test", "test", "Testing IRC") // Assert some basic things about the initial state of the Conn struct - if me := c.cfg.Me; me.Nick != "test" || me.Ident != "test" || + me := c.cfg.Me + if me.Nick != "test" || me.Ident != "test" || me.Name != "Testing IRC" || me.Host != "" { t.Errorf("Conn.cfg.Me not correctly initialised.") } @@ -126,18 +127,21 @@ func TestClientAndStateTracking(t *testing.T) { t.Errorf("Incorrect number of Removers (%d != %d) when adding state handlers.", len(c.stRemovers), len(stHandlers)) } + if neu := c.Me(); neu.Nick != me.Nick || neu.Ident != me.Ident || + neu.Name != me.Name || neu.Host != me.Host { + t.Errorf("Enabling state tracking erased information about me!") + } // We're expecting the untracked me to be replaced by a tracked one if c.st == nil { t.Errorf("State tracker not enabled correctly.") } - if me := c.cfg.Me; me.Nick != "test" || me.Ident != "test" || + if me = c.cfg.Me; me.Nick != "test" || me.Ident != "test" || me.Name != "Testing IRC" || me.Host != "" { t.Errorf("Enabling state tracking did not replace Me correctly.") } // Now, shim in the mock state tracker and test disabling state tracking - me := c.cfg.Me c.st = st gomock.InOrder( st.EXPECT().Me().Return(me),