gearman-go/gearman/client/client_test.go

42 lines
815 B
Go
Raw Normal View History

package client
import (
"bitbucket.org/mikespook/gearman-go/gearman"
"testing"
)
var client *Client
func init() {
client = NewClient()
}
2011-05-24 13:20:22 +08:00
func TestClientAddServer(t *testing.T) {
t.Log("Add local server 127.0.0.1:4730")
if err := client.AddServer("127.0.0.1:4730"); err != nil {
t.Error(err)
}
}
2011-05-24 13:20:22 +08:00
func TestClientEcho(t *testing.T) {
if echo, err := client.Echo([]byte("Hello world")); err != nil {
t.Error(err)
} else {
t.Log(echo)
}
}
2011-05-24 13:20:22 +08:00
func TestClientDo(t *testing.T) {
if handle, err := client.Do("ToUpper", []byte("abcdef"), gearman.JOB_LOW|gearman.JOB_BG); err != nil {
2011-05-19 23:29:34 +08:00
t.Error(err)
} else {
t.Log(handle)
2011-05-19 23:29:34 +08:00
}
}
2011-05-24 13:20:22 +08:00
func TestClientClose(t *testing.T) {
if err := client.Close(); err != nil {
t.Error(err)
}
}