From 770c5eb5ac196c02824a074caffe9e8c9acd9d94 Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Tue, 23 Aug 2011 10:52:16 +0100 Subject: [PATCH] Use ExpectNothing() to make sure handlers don't generate unexpected output. --- client/handlers_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client/handlers_test.go b/client/handlers_test.go index de5a30a..223ba2d 100644 --- a/client/handlers_test.go +++ b/client/handlers_test.go @@ -17,7 +17,7 @@ func TestPING(t *testing.T) { // Test the handler for 001 / RPL_WELCOME func Test001(t *testing.T) { - _, c := setUp(t) + m, c := setUp(t) // Setup a mock event dispatcher to test correct triggering of "connected" flag := false @@ -30,6 +30,8 @@ func Test001(t *testing.T) { // Call handler with a valid 001 line c.h_001(parseLine(":irc.server.org 001 test :Welcome to IRC test!ident@somehost.com")) + // Should result in no response to server + m.ExpectNothing() // Check that the event was dispatched correctly if !flag { @@ -74,7 +76,7 @@ func Test433(t *testing.T) { // Test the handler for NICK messages func TestNICK(t *testing.T) { - _, c := setUp(t) + m, c := setUp(t) c.Debug = true // Assert that the nick set in setUp() is still "test" (just in case) @@ -84,6 +86,10 @@ func TestNICK(t *testing.T) { // Call handler with a NICK line changing "our" nick to test1. c.h_NICK(parseLine(":test!test@somehost.com NICK :test1")) + // Should generate no response to server + m.ExpectNothing() + + // Verify that our Nick has changed if c.Me.Nick != "test1" { t.Errorf("NICK did not result in changing our nick.") }