go-ircevent/irc_test.go
2013-03-13 12:50:29 +01:00

48 lines
1.1 KiB
Go

package irc
import (
// "github.com/thoj/go-ircevent"
"testing"
)
func TestConnection(t *testing.T) {
irccon := IRC("go-eventirc", "go-eventirc")
irccon.VerboseCallbackHandler = true
err := irccon.Connect("irc.freenode.net:6667")
if err != nil {
t.Fatal("Can't connect to freenode.")
}
irccon.AddCallback("001", func(e *Event) { irccon.Join("#go-eventirc") })
irccon.AddCallback("366", func(e *Event) {
irccon.Privmsg("#go-eventirc", "Test Message\n")
irccon.Nick("go-eventnewnick")
})
irccon.AddCallback("NICK", func(e *Event) {
irccon.Quit()
irccon.log.Printf("NICKdf\n")
if irccon.nickcurrent == "go-eventnewnick" {
t.Fatal("Nick change did not work!")
}
})
irccon.Loop()
}
func TestConnectionSSL(t *testing.T) {
irccon := IRC("go-eventirc", "go-eventirc")
irccon.VerboseCallbackHandler = true
irccon.UseTLS = true
err := irccon.Connect("irc.freenode.net:7000")
if err != nil {
t.Fatal("Can't connect to freenode.")
}
irccon.AddCallback("001", func(e *Event) { irccon.Join("#go-eventirc") })
irccon.AddCallback("366", func(e *Event) {
irccon.Privmsg("#go-eventirc", "Test Message\n")
irccon.Quit()
})
irccon.Loop()
}