-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_test.go
48 lines (43 loc) · 999 Bytes
/
client_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package goq
import (
"github.com/pfdtk/goq/connect"
"github.com/pfdtk/goq/task"
"github.com/pfdtk/goq/test"
"testing"
)
func TestClient(t *testing.T) {
c := NewClient(&ClientConfig{})
// connect
conn := test.GetRedis()
c.AddRedisConnect(task.Conn, conn)
err := task.NewDemoTask().Dispatch(
[]byte("test payload"),
task.WithDelay(10),
task.WithPayloadUnique([]byte("test payload"), 10),
)
if err != nil {
t.Error(err)
}
}
func TestDispatch(t *testing.T) {
c := NewClient(&ClientConfig{})
// connect
conn := test.GetRedis()
c.AddRedisConnect(task.Conn, conn)
err := c.Dispatch(task.NewDemoTask(), []byte("test"))
if err != nil {
t.Error(err)
}
}
func TestChain_Dispatch(t *testing.T) {
// connect
conn := test.GetRedis()
connect.AddRedisConnect(task.Conn, conn)
t1 := task.NewDemoTask().Message([]byte("test chain 1"))
t2 := task.NewDemoTask().Message([]byte("test chain 2"))
c := task.NewChain(t1, t2)
err := c.Dispatch()
if err != nil {
t.Error(err)
}
}