gearman-go/client/pool_test.go

53 lines
1.0 KiB
Go
Raw Normal View History

2013-01-08 17:23:10 +08:00
package client
import (
2013-01-24 18:13:02 +08:00
"testing"
2013-01-08 17:23:10 +08:00
)
var (
pool = NewPool()
)
func TestPoolAdd(t *testing.T) {
t.Log("Add servers")
if err := pool.Add("127.0.0.1:4730", 1); err != nil {
t.Error(err)
}
if err := pool.Add("127.0.0.2:4730", 1); err != nil {
t.Error(err)
}
2013-01-24 18:13:02 +08:00
if len(pool.clients) != 2 {
t.Errorf("2 servers expected, %d got.", len(pool.clients))
2013-01-08 17:23:10 +08:00
}
}
2013-01-24 18:13:02 +08:00
/*
2013-01-23 17:25:38 +08:00
2013-01-08 17:23:10 +08:00
func TestPoolEcho(t *testing.T) {
pool.JobHandler = func(job *Job) error {
echo := string(job.Data)
if echo == "Hello world" {
t.Log(echo)
} else {
t.Errorf("Invalid echo data: %s", job.Data)
}
return nil
}
pool.Echo([]byte("Hello world"))
}
2013-01-24 18:13:02 +08:00
2013-01-08 17:23:10 +08:00
func TestPoolDo(t *testing.T) {
if addr, handle, err := pool.Do("ToUpper", []byte("abcdef"), JOB_LOW|JOB_BG); err != nil {
t.Error(err)
} else {
t.Log(handle)
}
}
2013-01-24 18:13:02 +08:00
*/
2013-01-08 17:23:10 +08:00
func TestPoolClose(t *testing.T) {
2013-01-18 17:03:45 +08:00
return
2013-01-08 17:23:10 +08:00
if err := pool.Close(); err != nil {
t.Error(err)
}
}