Merge pull request #83 from tetheredge/testing

Testing
This commit is contained in:
Thomas Jager 2016-08-03 10:57:04 +02:00 committed by GitHub
commit 30fbca01f1
2 changed files with 17 additions and 17 deletions

View File

@ -136,8 +136,7 @@ func (irc *Connection) RunCallbacks(event *Event) {
func (irc *Connection) setupCallbacks() {
irc.events = make(map[string]map[int]func(*Event))
//Handle error events. This has to be called in a new thred to allow
//readLoop to exit
//Handle error events.
irc.AddCallback("ERROR", func(e *Event) { irc.Disconnect() })
//Handle ping events

View File

@ -95,8 +95,7 @@ func TestConnectionEmptyNick(t *testing.T) {
func TestRemoveCallback(t *testing.T) {
irccon := IRC("go-eventirc", "go-eventirc")
irccon.VerboseCallbackHandler = verbose_tests
irccon.Debug = debug_tests
debugTest(irccon)
done := make(chan int, 10)
@ -123,8 +122,7 @@ func TestRemoveCallback(t *testing.T) {
func TestWildcardCallback(t *testing.T) {
irccon := IRC("go-eventirc", "go-eventirc")
irccon.VerboseCallbackHandler = verbose_tests
irccon.Debug = debug_tests
debugTest(irccon)
done := make(chan int, 10)
@ -147,8 +145,7 @@ func TestWildcardCallback(t *testing.T) {
func TestClearCallback(t *testing.T) {
irccon := IRC("go-eventirc", "go-eventirc")
irccon.VerboseCallbackHandler = verbose_tests
irccon.Debug = debug_tests
debugTest(irccon)
done := make(chan int, 10)
@ -192,11 +189,10 @@ func TestConnection(t *testing.T) {
ircnick1 := randStr(8)
ircnick2 := randStr(8)
irccon1 := IRC(ircnick1, "IRCTest1")
irccon1.VerboseCallbackHandler = verbose_tests
irccon1.Debug = debug_tests
debugTest(irccon1)
irccon2 := IRC(ircnick2, "IRCTest2")
irccon2.VerboseCallbackHandler = verbose_tests
irccon2.Debug = debug_tests
debugTest(irccon2)
teststr := randStr(20)
testmsgok := make(chan bool, 1)
@ -269,8 +265,8 @@ func TestConnection(t *testing.T) {
func TestReconnect(t *testing.T) {
ircnick1 := randStr(8)
irccon := IRC(ircnick1, "IRCTestRe")
irccon.VerboseCallbackHandler = verbose_tests
irccon.Debug = debug_tests
debugTest(irccon)
connects := 0
irccon.AddCallback("001", func(e *Event) { irccon.Join(channel) })
@ -281,7 +277,7 @@ func TestReconnect(t *testing.T) {
irccon.Quit()
} else {
irccon.Privmsgf(channel, "Connection nr %d\n", connects)
time.Sleep(100) //Meed to let the thraed actually send before closing socket
time.Sleep(100) //Need to let the thraed actually send before closing socket
irccon.Disconnect()
}
})
@ -301,8 +297,7 @@ func TestReconnect(t *testing.T) {
func TestConnectionSSL(t *testing.T) {
ircnick1 := randStr(8)
irccon := IRC(ircnick1, "IRCTestSSL")
irccon.VerboseCallbackHandler = verbose_tests
irccon.Debug = debug_tests
debugTest(irccon)
irccon.UseTLS = true
irccon.TLSConfig = &tls.Config{InsecureSkipVerify: true}
irccon.AddCallback("001", func(e *Event) { irccon.Join(channel) })
@ -329,3 +324,9 @@ func randStr(n int) string {
}
return string(b)
}
func debugTest(irccon *Connection) *Connection {
irccon.VerboseCallbackHandler = verbose_tests
irccon.Debug = debug_tests
return irccon
}