From daadb2c96e215fa2bcdb2c05af9c03d47bd87329 Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Fri, 9 Sep 2011 23:02:33 +0100 Subject: [PATCH] Test the TOPIC handler. --- client/handlers_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/client/handlers_test.go b/client/handlers_test.go index a644304..05307c4 100644 --- a/client/handlers_test.go +++ b/client/handlers_test.go @@ -390,3 +390,32 @@ func TestMODE(t *testing.T) { m.ExpectNothing() c.ExpectError() } + +// Test the handler for TOPIC messages +func TestTOPIC(t *testing.T) { + m, c := setUp(t) + defer tearDown(m, c) + + // Create #test1 so we have a channel to set the topic of + test1 := c.NewChannel("#test1") + + // Assert that it has no topic originally + if test1.Topic != "" { + t.Errorf("Test channel already has a topic.") + } + + // Send a TOPIC line + c.h_TOPIC(parseLine(":user1!ident1@host1.com TOPIC #test1 :something something")) + m.ExpectNothing() + c.ExpectNoErrors() + + // Make sure the channel's topic has been changed + if test1.Topic != "something something" { + t.Errorf("Topic of test channel not set correctly.") + } + + // Check error paths -- send a topic for an unknown channel + c.h_TOPIC(parseLine(":user1!ident1@host1.com TOPIC #test2 :dark side")) + m.ExpectNothing() + c.ExpectError() +}