-
Notifications
You must be signed in to change notification settings - Fork 0
/
producer_test.go
42 lines (39 loc) · 925 Bytes
/
producer_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
package delay_queue
import (
"context"
"fmt"
"sync"
"testing"
"time"
)
func TestPushMessage(t *testing.T) {
ctx := context.TODO()
var wg sync.WaitGroup
for {
for i := 0; i < 10; i++ {
wg.Add(1)
go func(i int) {
defer wg.Done()
err := NewProducer().RegisterRedis(defaultRedis()).PushMessage(ctx, "delay-queue-1", fmt.Sprintf("测试数据:%d=%d", time.Now().UnixNano(), i))
if err != nil {
t.Error("PushMessage Fail!")
}
}(i)
}
wg.Wait()
fmt.Println("next")
time.Sleep(100 * time.Millisecond)
}
}
func TestZRem(t *testing.T) {
ctx := context.TODO()
message := "测试数据"
err := NewProducer().RegisterRedis(defaultRedis()).PushMessage(ctx, "delay-queue-1", message)
if err != nil {
t.Error("PushMessage Fail!")
}
err = NewProducer().RegisterRedis(defaultRedis()).DeleteMessage(ctx, "delay-queue-1", message)
if err != nil {
t.Error("DeleteMessage Fail!")
}
}