2012-05-22 20:05:39 +08:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
var client *Client
|
|
|
|
|
|
|
|
func TestClientAddServer(t *testing.T) {
|
|
|
|
t.Log("Add local server 127.0.0.1:4730")
|
|
|
|
var err error
|
2012-05-23 15:22:29 +08:00
|
|
|
if client, err = New("127.0.0.1:4730"); err != nil {
|
2012-05-22 20:05:39 +08:00
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|
2012-05-24 19:21:30 +08:00
|
|
|
/*
|
2012-05-22 20:05:39 +08:00
|
|
|
func TestClientEcho(t *testing.T) {
|
|
|
|
client.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
|
|
|
|
}
|
|
|
|
client.Echo([]byte("Hello world"))
|
|
|
|
}
|
2012-05-24 19:21:30 +08:00
|
|
|
*/
|
|
|
|
/*
|
2012-05-22 20:05:39 +08:00
|
|
|
func TestClientDo(t *testing.T) {
|
2012-05-23 15:22:29 +08:00
|
|
|
if handle, err := client.Do("ToUpper", []byte("abcdef"), JOB_LOW|JOB_BG); err != nil {
|
2012-05-22 20:05:39 +08:00
|
|
|
t.Error(err)
|
|
|
|
} else {
|
|
|
|
t.Log(handle)
|
|
|
|
}
|
|
|
|
}
|
2012-05-24 19:21:30 +08:00
|
|
|
*/
|
2012-05-22 20:05:39 +08:00
|
|
|
func TestClientClose(t *testing.T) {
|
2013-01-08 17:23:10 +08:00
|
|
|
return
|
2012-05-22 20:05:39 +08:00
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|