add helper function to degub tests

This commit is contained in:
Taylor Etheredge 2016-08-02 21:00:42 -05:00
parent 62964f02b0
commit 7c392f5a61

View File

@ -95,8 +95,7 @@ func TestConnectionEmptyNick(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 = verbose_tests debugTest(irccon)
irccon.Debug = debug_tests
done := make(chan int, 10) done := make(chan int, 10)
@ -123,8 +122,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 = verbose_tests debugTest(irccon)
irccon.Debug = debug_tests
done := make(chan int, 10) done := make(chan int, 10)
@ -147,8 +145,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 = verbose_tests debugTest(irccon)
irccon.Debug = debug_tests
done := make(chan int, 10) done := make(chan int, 10)
@ -192,11 +189,10 @@ func TestConnection(t *testing.T) {
ircnick1 := randStr(8) ircnick1 := randStr(8)
ircnick2 := randStr(8) ircnick2 := randStr(8)
irccon1 := IRC(ircnick1, "IRCTest1") irccon1 := IRC(ircnick1, "IRCTest1")
irccon1.VerboseCallbackHandler = verbose_tests debugTest(irccon1)
irccon1.Debug = debug_tests
irccon2 := IRC(ircnick2, "IRCTest2") irccon2 := IRC(ircnick2, "IRCTest2")
irccon2.VerboseCallbackHandler = verbose_tests debugTest(irccon2)
irccon2.Debug = debug_tests
teststr := randStr(20) teststr := randStr(20)
testmsgok := make(chan bool, 1) testmsgok := make(chan bool, 1)
@ -269,8 +265,8 @@ func TestConnection(t *testing.T) {
func TestReconnect(t *testing.T) { func TestReconnect(t *testing.T) {
ircnick1 := randStr(8) ircnick1 := randStr(8)
irccon := IRC(ircnick1, "IRCTestRe") irccon := IRC(ircnick1, "IRCTestRe")
irccon.VerboseCallbackHandler = verbose_tests debugTest(irccon)
irccon.Debug = debug_tests
connects := 0 connects := 0
irccon.AddCallback("001", func(e *Event) { irccon.Join(channel) }) irccon.AddCallback("001", func(e *Event) { irccon.Join(channel) })
@ -281,7 +277,7 @@ func TestReconnect(t *testing.T) {
irccon.Quit() irccon.Quit()
} else { } else {
irccon.Privmsgf(channel, "Connection nr %d\n", connects) 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() irccon.Disconnect()
} }
}) })
@ -301,8 +297,7 @@ func TestReconnect(t *testing.T) {
func TestConnectionSSL(t *testing.T) { func TestConnectionSSL(t *testing.T) {
ircnick1 := randStr(8) ircnick1 := randStr(8)
irccon := IRC(ircnick1, "IRCTestSSL") irccon := IRC(ircnick1, "IRCTestSSL")
irccon.VerboseCallbackHandler = verbose_tests debugTest(irccon)
irccon.Debug = debug_tests
irccon.UseTLS = true irccon.UseTLS = true
irccon.TLSConfig = &tls.Config{InsecureSkipVerify: true} irccon.TLSConfig = &tls.Config{InsecureSkipVerify: true}
irccon.AddCallback("001", func(e *Event) { irccon.Join(channel) }) irccon.AddCallback("001", func(e *Event) { irccon.Join(channel) })
@ -329,3 +324,9 @@ func randStr(n int) string {
} }
return string(b) return string(b)
} }
func debugTest(irccon *Connection) *Connection {
irccon.VerboseCallbackHandler = verbose_tests
irccon.Debug = debug_tests
return irccon
}