From 83da879ad387a30e7fb3c454628d297ea278384f Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Tue, 23 Aug 2011 11:06:06 +0100 Subject: [PATCH] Add tearDown() to all tests. --- client/commands_test.go | 1 + client/handlers_test.go | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/client/commands_test.go b/client/commands_test.go index b82c0f1..2e7cd1b 100644 --- a/client/commands_test.go +++ b/client/commands_test.go @@ -4,6 +4,7 @@ import "testing" func TestClientCommands(t *testing.T) { m, c := setUp(t) + defer tearDown(m, c) c.Pass("password") m.Expect("PASS password") diff --git a/client/handlers_test.go b/client/handlers_test.go index 6e4ecf7..0457413 100644 --- a/client/handlers_test.go +++ b/client/handlers_test.go @@ -10,7 +10,8 @@ import ( // in this file will call their respective handlers synchronously, otherwise // testing becomes more difficult. func TestPING(t *testing.T) { - m, _ := setUp(t) + m, c := setUp(t) + defer tearDown(m, c) m.Send("PING :1234567890") m.Expect("PONG :1234567890") } @@ -18,6 +19,7 @@ func TestPING(t *testing.T) { // Test the handler for 001 / RPL_WELCOME func Test001(t *testing.T) { m, c := setUp(t) + defer tearDown(m, c) // Setup a mock event dispatcher to test correct triggering of "connected" flag := false @@ -47,6 +49,7 @@ func Test001(t *testing.T) { // Test the handler for 433 / ERR_NICKNAMEINUSE func Test433(t *testing.T) { m, c := setUp(t) + defer tearDown(m, c) // Assert that the nick set in setUp() is still "test" (just in case) if c.Me.Nick != "test" { @@ -77,7 +80,7 @@ func Test433(t *testing.T) { // Test the handler for NICK messages func TestNICK(t *testing.T) { m, c := setUp(t) - c.Debug = true + defer tearDown(m, c) // Assert that the nick set in setUp() is still "test" (just in case) if c.Me.Nick != "test" { @@ -122,6 +125,7 @@ func TestNICK(t *testing.T) { func TestCTCP(t *testing.T) { m, c := setUp(t) + defer tearDown(m, c) // Call handler with CTCP VERSION c.h_CTCP(parseLine(":blah!moo@cows.com PRIVMSG test :\001VERSION\001"))