Add more IRC client tests

This commit is contained in:
Ken-Håvard Lieng 2015-06-11 04:57:52 +02:00
parent 4f0ad5e6d9
commit 6a5680e299
4 changed files with 148 additions and 26 deletions

View file

@ -59,10 +59,6 @@ func (c *Client) Connected() bool {
return c.connected
}
func (c *Client) Pass(password string) {
c.write("PASS " + password)
}
func (c *Client) Nick(nick string) {
c.Write("NICK " + nick)
@ -71,10 +67,6 @@ func (c *Client) Nick(nick string) {
c.lock.Unlock()
}
func (c *Client) User(username, realname string) {
c.writef("USER %s 0 * :%s", username, realname)
}
func (c *Client) Oper(name, password string) {
c.Write("OPER " + name + " " + password)
}
@ -89,7 +81,9 @@ func (c *Client) Quit() {
c.write("QUIT")
}
close(c.quit)
c.lock.Lock()
c.conn.Close()
c.lock.Unlock()
}()
}
@ -128,3 +122,23 @@ func (c *Client) Whois(nick string) {
func (c *Client) Away(message string) {
c.Write("AWAY :" + message)
}
func (c *Client) writePass(password string) {
c.write("PASS " + password)
}
func (c *Client) writeNick(nick string) {
c.write("NICK " + nick)
}
func (c *Client) writeUser(username, realname string) {
c.writef("USER %s 0 * :%s", username, realname)
}
func (c *Client) register() {
if c.Password != "" {
c.writePass(c.Password)
}
c.writeNick(c.nick)
c.writeUser(c.Username, c.Realname)
}