Fix test cases. Added sleep before Quit

This commit is contained in:
Thomas Jager 2014-02-12 08:40:30 +01:00
parent bbbdd715fa
commit 84a0cb60ed

View File

@ -3,11 +3,13 @@ package irc
import ( import (
// "github.com/thoj/go-ircevent" // "github.com/thoj/go-ircevent"
"testing" "testing"
"time"
) )
func TestConnection(t *testing.T) { func TestConnection(t *testing.T) {
irccon := IRC("go-eventirc", "go-eventirc") irccon := IRC("go-eventirc", "go-eventirc")
irccon.VerboseCallbackHandler = true irccon.VerboseCallbackHandler = true
irccon.Debug = true
err := irccon.Connect("irc.freenode.net:6667") err := irccon.Connect("irc.freenode.net:6667")
if err != nil { if err != nil {
t.Fatal("Can't connect to freenode.") t.Fatal("Can't connect to freenode.")
@ -30,6 +32,7 @@ func TestConnection(t *testing.T) {
func TestConnectionSSL(t *testing.T) { func TestConnectionSSL(t *testing.T) {
irccon := IRC("go-eventirc", "go-eventirc") irccon := IRC("go-eventirc", "go-eventirc")
irccon.VerboseCallbackHandler = true irccon.VerboseCallbackHandler = true
irccon.Debug = true
irccon.UseTLS = true irccon.UseTLS = true
err := irccon.Connect("irc.freenode.net:7000") err := irccon.Connect("irc.freenode.net:7000")
if err != nil { if err != nil {
@ -39,6 +42,7 @@ func TestConnectionSSL(t *testing.T) {
irccon.AddCallback("366", func(e *Event) { irccon.AddCallback("366", func(e *Event) {
irccon.Privmsg("#go-eventirc", "Test Message\n") irccon.Privmsg("#go-eventirc", "Test Message\n")
time.Sleep(2 * time.Second)
irccon.Quit() irccon.Quit()
}) })
@ -48,6 +52,7 @@ func TestConnectionSSL(t *testing.T) {
func TestRemoveCallback(t *testing.T) { func TestRemoveCallback(t *testing.T) {
irccon := IRC("go-eventirc", "go-eventirc") irccon := IRC("go-eventirc", "go-eventirc")
irccon.VerboseCallbackHandler = true irccon.VerboseCallbackHandler = true
irccon.Debug = true
done := make(chan int, 10) done := make(chan int, 10)
@ -75,6 +80,7 @@ func TestRemoveCallback(t *testing.T) {
func TestWildcardCallback(t *testing.T) { func TestWildcardCallback(t *testing.T) {
irccon := IRC("go-eventirc", "go-eventirc") irccon := IRC("go-eventirc", "go-eventirc")
irccon.VerboseCallbackHandler = true irccon.VerboseCallbackHandler = true
irccon.Debug = true
done := make(chan int, 10) done := make(chan int, 10)
@ -98,6 +104,7 @@ func TestWildcardCallback(t *testing.T) {
func TestClearCallback(t *testing.T) { func TestClearCallback(t *testing.T) {
irccon := IRC("go-eventirc", "go-eventirc") irccon := IRC("go-eventirc", "go-eventirc")
irccon.VerboseCallbackHandler = true irccon.VerboseCallbackHandler = true
irccon.Debug = true
done := make(chan int, 10) done := make(chan int, 10)