gearman-go/src/pkg/gearman/client_test.go

54 lines
970 B
Go
Raw Normal View History

package gearman
import (
"testing"
2011-05-19 23:29:34 +08:00
// "os"
)
var client *Client
func init() {
client = NewClient()
}
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)
}
}
func TestClientEcho(t * testing.T) {
if echo, err := client.Echo([]byte("Hello world")); err != nil {
t.Error(err)
} else {
t.Log(echo)
}
}
/*
2011-05-19 23:29:34 +08:00
func TestClientDo(t * testing.T) {
if handle, err := client.Do("ToUpper", []byte("abcdef"), JOB_LOW | 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
}
}
*/
/*
func TestClientLastResult(t * testing.T) {
job := client.LastResult()
if job == nil {
t.Error(os.NewError("job shuold be the echo."))
} else {
t.Log(job)
}
}
*/
func TestClientClose(t * testing.T) {
if err := client.Close(); err != nil {
t.Error(err)
}
}