go-ircevent/irc_test.go

48 lines
1.1 KiB
Go
Raw Normal View History

2012-11-05 22:46:47 +00:00
package irc
import (
2013-03-13 11:50:29 +00:00
// "github.com/thoj/go-ircevent"
2012-11-05 22:46:47 +00:00
"testing"
)
func TestConnection(t *testing.T) {
2012-11-05 23:40:00 +00:00
irccon := IRC("go-eventirc", "go-eventirc")
irccon.VerboseCallbackHandler = true
2012-11-05 22:46:47 +00:00
err := irccon.Connect("irc.freenode.net:6667")
if err != nil {
t.Fatal("Can't connect to freenode.")
}
2012-11-05 23:40:00 +00:00
irccon.AddCallback("001", func(e *Event) { irccon.Join("#go-eventirc") })
2012-11-05 22:46:47 +00:00
2013-03-13 11:50:29 +00:00
irccon.AddCallback("366", func(e *Event) {
2012-11-05 23:40:00 +00:00
irccon.Privmsg("#go-eventirc", "Test Message\n")
2013-03-13 11:50:29 +00:00
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!")
}
2012-11-05 22:46:47 +00:00
})
irccon.Loop()
2012-11-05 23:40:00 +00:00
}
2012-11-05 22:46:47 +00:00
2012-11-05 23:40:00 +00:00
func TestConnectionSSL(t *testing.T) {
irccon := IRC("go-eventirc", "go-eventirc")
irccon.VerboseCallbackHandler = true
2012-11-11 09:51:02 +00:00
irccon.UseTLS = true
2012-11-05 23:40:00 +00:00
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") })
2012-11-05 22:46:47 +00:00
2013-03-13 11:50:29 +00:00
irccon.AddCallback("366", func(e *Event) {
2012-11-05 23:40:00 +00:00
irccon.Privmsg("#go-eventirc", "Test Message\n")
2013-03-13 11:50:29 +00:00
irccon.Quit()
2012-11-05 23:40:00 +00:00
})
irccon.Loop()
2012-11-05 22:46:47 +00:00
}