2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-11-13 04:46:39 +08:00

Rename asynqtest package to testutil

This commit is contained in:
Ken Hibino 2022-03-19 07:16:55 -07:00
parent 1acd62c760
commit e939b5d166
20 changed files with 63 additions and 63 deletions

View File

@ -10,9 +10,9 @@ import (
"time" "time"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
h "github.com/hibiken/asynq/internal/asynqtest"
"github.com/hibiken/asynq/internal/base" "github.com/hibiken/asynq/internal/base"
"github.com/hibiken/asynq/internal/rdb" "github.com/hibiken/asynq/internal/rdb"
h "github.com/hibiken/asynq/internal/testutil"
) )
func TestAggregator(t *testing.T) { func TestAggregator(t *testing.T) {

View File

@ -14,8 +14,8 @@ import (
"github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts" "github.com/google/go-cmp/cmp/cmpopts"
h "github.com/hibiken/asynq/internal/asynqtest"
"github.com/hibiken/asynq/internal/log" "github.com/hibiken/asynq/internal/log"
h "github.com/hibiken/asynq/internal/testutil"
) )
//============================================================================ //============================================================================

View File

@ -12,7 +12,7 @@ import (
"testing" "testing"
"time" "time"
h "github.com/hibiken/asynq/internal/asynqtest" h "github.com/hibiken/asynq/internal/testutil"
) )
// Creates a new task of type "task<n>" with payload {"data": n}. // Creates a new task of type "task<n>" with payload {"data": n}.

View File

@ -12,8 +12,8 @@ import (
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts" "github.com/google/go-cmp/cmp/cmpopts"
h "github.com/hibiken/asynq/internal/asynqtest"
"github.com/hibiken/asynq/internal/base" "github.com/hibiken/asynq/internal/base"
h "github.com/hibiken/asynq/internal/testutil"
) )
func TestClientEnqueueWithProcessAtOption(t *testing.T) { func TestClientEnqueueWithProcessAtOption(t *testing.T) {

View File

@ -10,9 +10,9 @@ import (
"time" "time"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
h "github.com/hibiken/asynq/internal/asynqtest"
"github.com/hibiken/asynq/internal/base" "github.com/hibiken/asynq/internal/base"
"github.com/hibiken/asynq/internal/rdb" "github.com/hibiken/asynq/internal/rdb"
h "github.com/hibiken/asynq/internal/testutil"
) )
func TestForwarder(t *testing.T) { func TestForwarder(t *testing.T) {

View File

@ -12,10 +12,10 @@ import (
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts" "github.com/google/go-cmp/cmp/cmpopts"
h "github.com/hibiken/asynq/internal/asynqtest"
"github.com/hibiken/asynq/internal/base" "github.com/hibiken/asynq/internal/base"
"github.com/hibiken/asynq/internal/rdb" "github.com/hibiken/asynq/internal/rdb"
"github.com/hibiken/asynq/internal/testbroker" "github.com/hibiken/asynq/internal/testbroker"
h "github.com/hibiken/asynq/internal/testutil"
"github.com/hibiken/asynq/internal/timeutil" "github.com/hibiken/asynq/internal/timeutil"
) )

View File

@ -15,9 +15,9 @@ import (
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts" "github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid" "github.com/google/uuid"
h "github.com/hibiken/asynq/internal/asynqtest"
"github.com/hibiken/asynq/internal/base" "github.com/hibiken/asynq/internal/base"
"github.com/hibiken/asynq/internal/rdb" "github.com/hibiken/asynq/internal/rdb"
h "github.com/hibiken/asynq/internal/testutil"
"github.com/hibiken/asynq/internal/timeutil" "github.com/hibiken/asynq/internal/timeutil"
) )

View File

@ -10,19 +10,19 @@ import (
"testing" "testing"
"time" "time"
"github.com/hibiken/asynq/internal/asynqtest"
"github.com/hibiken/asynq/internal/base" "github.com/hibiken/asynq/internal/base"
"github.com/hibiken/asynq/internal/testutil"
) )
func BenchmarkEnqueue(b *testing.B) { func BenchmarkEnqueue(b *testing.B) {
r := setup(b) r := setup(b)
ctx := context.Background() ctx := context.Background()
msg := asynqtest.NewTaskMessage("task1", nil) msg := testutil.NewTaskMessage("task1", nil)
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
b.StopTimer() b.StopTimer()
asynqtest.FlushDB(b, r.client) testutil.FlushDB(b, r.client)
b.StartTimer() b.StartTimer()
if err := r.Enqueue(ctx, msg); err != nil { if err := r.Enqueue(ctx, msg); err != nil {
@ -45,7 +45,7 @@ func BenchmarkEnqueueUnique(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
b.StopTimer() b.StopTimer()
asynqtest.FlushDB(b, r.client) testutil.FlushDB(b, r.client)
b.StartTimer() b.StartTimer()
if err := r.EnqueueUnique(ctx, msg, uniqueTTL); err != nil { if err := r.EnqueueUnique(ctx, msg, uniqueTTL); err != nil {
@ -57,13 +57,13 @@ func BenchmarkEnqueueUnique(b *testing.B) {
func BenchmarkSchedule(b *testing.B) { func BenchmarkSchedule(b *testing.B) {
r := setup(b) r := setup(b)
ctx := context.Background() ctx := context.Background()
msg := asynqtest.NewTaskMessage("task1", nil) msg := testutil.NewTaskMessage("task1", nil)
processAt := time.Now().Add(3 * time.Minute) processAt := time.Now().Add(3 * time.Minute)
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
b.StopTimer() b.StopTimer()
asynqtest.FlushDB(b, r.client) testutil.FlushDB(b, r.client)
b.StartTimer() b.StartTimer()
if err := r.Schedule(ctx, msg, processAt); err != nil { if err := r.Schedule(ctx, msg, processAt); err != nil {
@ -87,7 +87,7 @@ func BenchmarkScheduleUnique(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
b.StopTimer() b.StopTimer()
asynqtest.FlushDB(b, r.client) testutil.FlushDB(b, r.client)
b.StartTimer() b.StartTimer()
if err := r.ScheduleUnique(ctx, msg, processAt, uniqueTTL); err != nil { if err := r.ScheduleUnique(ctx, msg, processAt, uniqueTTL); err != nil {
@ -103,9 +103,9 @@ func BenchmarkDequeueSingleQueue(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
b.StopTimer() b.StopTimer()
asynqtest.FlushDB(b, r.client) testutil.FlushDB(b, r.client)
for i := 0; i < 10; i++ { for i := 0; i < 10; i++ {
m := asynqtest.NewTaskMessageWithQueue( m := testutil.NewTaskMessageWithQueue(
fmt.Sprintf("task%d", i), nil, base.DefaultQueueName) fmt.Sprintf("task%d", i), nil, base.DefaultQueueName)
if err := r.Enqueue(ctx, m); err != nil { if err := r.Enqueue(ctx, m); err != nil {
b.Fatalf("Enqueue failed: %v", err) b.Fatalf("Enqueue failed: %v", err)
@ -127,10 +127,10 @@ func BenchmarkDequeueMultipleQueues(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
b.StopTimer() b.StopTimer()
asynqtest.FlushDB(b, r.client) testutil.FlushDB(b, r.client)
for i := 0; i < 10; i++ { for i := 0; i < 10; i++ {
for _, qname := range qnames { for _, qname := range qnames {
m := asynqtest.NewTaskMessageWithQueue( m := testutil.NewTaskMessageWithQueue(
fmt.Sprintf("%s_task%d", qname, i), nil, qname) fmt.Sprintf("%s_task%d", qname, i), nil, qname)
if err := r.Enqueue(ctx, m); err != nil { if err := r.Enqueue(ctx, m); err != nil {
b.Fatalf("Enqueue failed: %v", err) b.Fatalf("Enqueue failed: %v", err)
@ -147,9 +147,9 @@ func BenchmarkDequeueMultipleQueues(b *testing.B) {
func BenchmarkDone(b *testing.B) { func BenchmarkDone(b *testing.B) {
r := setup(b) r := setup(b)
m1 := asynqtest.NewTaskMessage("task1", nil) m1 := testutil.NewTaskMessage("task1", nil)
m2 := asynqtest.NewTaskMessage("task2", nil) m2 := testutil.NewTaskMessage("task2", nil)
m3 := asynqtest.NewTaskMessage("task3", nil) m3 := testutil.NewTaskMessage("task3", nil)
msgs := []*base.TaskMessage{m1, m2, m3} msgs := []*base.TaskMessage{m1, m2, m3}
zs := []base.Z{ zs := []base.Z{
{Message: m1, Score: time.Now().Add(10 * time.Second).Unix()}, {Message: m1, Score: time.Now().Add(10 * time.Second).Unix()},
@ -161,9 +161,9 @@ func BenchmarkDone(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
b.StopTimer() b.StopTimer()
asynqtest.FlushDB(b, r.client) testutil.FlushDB(b, r.client)
asynqtest.SeedActiveQueue(b, r.client, msgs, base.DefaultQueueName) testutil.SeedActiveQueue(b, r.client, msgs, base.DefaultQueueName)
asynqtest.SeedLease(b, r.client, zs, base.DefaultQueueName) testutil.SeedLease(b, r.client, zs, base.DefaultQueueName)
b.StartTimer() b.StartTimer()
if err := r.Done(ctx, msgs[0]); err != nil { if err := r.Done(ctx, msgs[0]); err != nil {
@ -174,9 +174,9 @@ func BenchmarkDone(b *testing.B) {
func BenchmarkRetry(b *testing.B) { func BenchmarkRetry(b *testing.B) {
r := setup(b) r := setup(b)
m1 := asynqtest.NewTaskMessage("task1", nil) m1 := testutil.NewTaskMessage("task1", nil)
m2 := asynqtest.NewTaskMessage("task2", nil) m2 := testutil.NewTaskMessage("task2", nil)
m3 := asynqtest.NewTaskMessage("task3", nil) m3 := testutil.NewTaskMessage("task3", nil)
msgs := []*base.TaskMessage{m1, m2, m3} msgs := []*base.TaskMessage{m1, m2, m3}
zs := []base.Z{ zs := []base.Z{
{Message: m1, Score: time.Now().Add(10 * time.Second).Unix()}, {Message: m1, Score: time.Now().Add(10 * time.Second).Unix()},
@ -188,9 +188,9 @@ func BenchmarkRetry(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
b.StopTimer() b.StopTimer()
asynqtest.FlushDB(b, r.client) testutil.FlushDB(b, r.client)
asynqtest.SeedActiveQueue(b, r.client, msgs, base.DefaultQueueName) testutil.SeedActiveQueue(b, r.client, msgs, base.DefaultQueueName)
asynqtest.SeedLease(b, r.client, zs, base.DefaultQueueName) testutil.SeedLease(b, r.client, zs, base.DefaultQueueName)
b.StartTimer() b.StartTimer()
if err := r.Retry(ctx, msgs[0], time.Now().Add(1*time.Minute), "error", true /*isFailure*/); err != nil { if err := r.Retry(ctx, msgs[0], time.Now().Add(1*time.Minute), "error", true /*isFailure*/); err != nil {
@ -201,9 +201,9 @@ func BenchmarkRetry(b *testing.B) {
func BenchmarkArchive(b *testing.B) { func BenchmarkArchive(b *testing.B) {
r := setup(b) r := setup(b)
m1 := asynqtest.NewTaskMessage("task1", nil) m1 := testutil.NewTaskMessage("task1", nil)
m2 := asynqtest.NewTaskMessage("task2", nil) m2 := testutil.NewTaskMessage("task2", nil)
m3 := asynqtest.NewTaskMessage("task3", nil) m3 := testutil.NewTaskMessage("task3", nil)
msgs := []*base.TaskMessage{m1, m2, m3} msgs := []*base.TaskMessage{m1, m2, m3}
zs := []base.Z{ zs := []base.Z{
{Message: m1, Score: time.Now().Add(10 * time.Second).Unix()}, {Message: m1, Score: time.Now().Add(10 * time.Second).Unix()},
@ -215,9 +215,9 @@ func BenchmarkArchive(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
b.StopTimer() b.StopTimer()
asynqtest.FlushDB(b, r.client) testutil.FlushDB(b, r.client)
asynqtest.SeedActiveQueue(b, r.client, msgs, base.DefaultQueueName) testutil.SeedActiveQueue(b, r.client, msgs, base.DefaultQueueName)
asynqtest.SeedLease(b, r.client, zs, base.DefaultQueueName) testutil.SeedLease(b, r.client, zs, base.DefaultQueueName)
b.StartTimer() b.StartTimer()
if err := r.Archive(ctx, msgs[0], "error"); err != nil { if err := r.Archive(ctx, msgs[0], "error"); err != nil {
@ -228,9 +228,9 @@ func BenchmarkArchive(b *testing.B) {
func BenchmarkRequeue(b *testing.B) { func BenchmarkRequeue(b *testing.B) {
r := setup(b) r := setup(b)
m1 := asynqtest.NewTaskMessage("task1", nil) m1 := testutil.NewTaskMessage("task1", nil)
m2 := asynqtest.NewTaskMessage("task2", nil) m2 := testutil.NewTaskMessage("task2", nil)
m3 := asynqtest.NewTaskMessage("task3", nil) m3 := testutil.NewTaskMessage("task3", nil)
msgs := []*base.TaskMessage{m1, m2, m3} msgs := []*base.TaskMessage{m1, m2, m3}
zs := []base.Z{ zs := []base.Z{
{Message: m1, Score: time.Now().Add(10 * time.Second).Unix()}, {Message: m1, Score: time.Now().Add(10 * time.Second).Unix()},
@ -242,9 +242,9 @@ func BenchmarkRequeue(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
b.StopTimer() b.StopTimer()
asynqtest.FlushDB(b, r.client) testutil.FlushDB(b, r.client)
asynqtest.SeedActiveQueue(b, r.client, msgs, base.DefaultQueueName) testutil.SeedActiveQueue(b, r.client, msgs, base.DefaultQueueName)
asynqtest.SeedLease(b, r.client, zs, base.DefaultQueueName) testutil.SeedLease(b, r.client, zs, base.DefaultQueueName)
b.StartTimer() b.StartTimer()
if err := r.Requeue(ctx, msgs[0]); err != nil { if err := r.Requeue(ctx, msgs[0]); err != nil {
@ -258,7 +258,7 @@ func BenchmarkCheckAndEnqueue(b *testing.B) {
now := time.Now() now := time.Now()
var zs []base.Z var zs []base.Z
for i := -100; i < 100; i++ { for i := -100; i < 100; i++ {
msg := asynqtest.NewTaskMessage(fmt.Sprintf("task%d", i), nil) msg := testutil.NewTaskMessage(fmt.Sprintf("task%d", i), nil)
score := now.Add(time.Duration(i) * time.Second).Unix() score := now.Add(time.Duration(i) * time.Second).Unix()
zs = append(zs, base.Z{Message: msg, Score: score}) zs = append(zs, base.Z{Message: msg, Score: score})
} }
@ -266,8 +266,8 @@ func BenchmarkCheckAndEnqueue(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
b.StopTimer() b.StopTimer()
asynqtest.FlushDB(b, r.client) testutil.FlushDB(b, r.client)
asynqtest.SeedScheduledQueue(b, r.client, zs, base.DefaultQueueName) testutil.SeedScheduledQueue(b, r.client, zs, base.DefaultQueueName)
b.StartTimer() b.StartTimer()
if err := r.ForwardIfReady(base.DefaultQueueName); err != nil { if err := r.ForwardIfReady(base.DefaultQueueName); err != nil {

View File

@ -16,9 +16,9 @@ import (
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts" "github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid" "github.com/google/uuid"
h "github.com/hibiken/asynq/internal/asynqtest"
"github.com/hibiken/asynq/internal/base" "github.com/hibiken/asynq/internal/base"
"github.com/hibiken/asynq/internal/errors" "github.com/hibiken/asynq/internal/errors"
h "github.com/hibiken/asynq/internal/testutil"
"github.com/hibiken/asynq/internal/timeutil" "github.com/hibiken/asynq/internal/timeutil"
) )

View File

@ -19,9 +19,9 @@ import (
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts" "github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid" "github.com/google/uuid"
h "github.com/hibiken/asynq/internal/asynqtest"
"github.com/hibiken/asynq/internal/base" "github.com/hibiken/asynq/internal/base"
"github.com/hibiken/asynq/internal/errors" "github.com/hibiken/asynq/internal/errors"
h "github.com/hibiken/asynq/internal/testutil"
"github.com/hibiken/asynq/internal/timeutil" "github.com/hibiken/asynq/internal/timeutil"
) )

View File

@ -15,7 +15,7 @@ import (
"github.com/hibiken/asynq/internal/base" "github.com/hibiken/asynq/internal/base"
) )
var errRedisDown = errors.New("asynqtest: redis is down") var errRedisDown = errors.New("testutil: redis is down")
// TestBroker is a broker implementation which enables // TestBroker is a broker implementation which enables
// to simulate Redis failure in tests. // to simulate Redis failure in tests.

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT license // Use of this source code is governed by a MIT license
// that can be found in the LICENSE file. // that can be found in the LICENSE file.
package asynqtest package testutil
import ( import (
"time" "time"

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT license // Use of this source code is governed by a MIT license
// that can be found in the LICENSE file. // that can be found in the LICENSE file.
package asynqtest package testutil
import ( import (
"testing" "testing"

View File

@ -2,8 +2,8 @@
// Use of this source code is governed by a MIT license // Use of this source code is governed by a MIT license
// that can be found in the LICENSE file. // that can be found in the LICENSE file.
// Package asynqtest defines test helpers for asynq and its internal packages. // Package testutil defines test helpers for asynq and its internal packages.
package asynqtest package testutil
import ( import (
"context" "context"

View File

@ -10,9 +10,9 @@ import (
"time" "time"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
h "github.com/hibiken/asynq/internal/asynqtest"
"github.com/hibiken/asynq/internal/base" "github.com/hibiken/asynq/internal/base"
"github.com/hibiken/asynq/internal/rdb" "github.com/hibiken/asynq/internal/rdb"
h "github.com/hibiken/asynq/internal/testutil"
) )
func newCompletedTask(qname, tasktype string, payload []byte, completedAt time.Time) *base.TaskMessage { func newCompletedTask(qname, tasktype string, payload []byte, completedAt time.Time) *base.TaskMessage {

View File

@ -15,11 +15,11 @@ import (
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts" "github.com/google/go-cmp/cmp/cmpopts"
h "github.com/hibiken/asynq/internal/asynqtest"
"github.com/hibiken/asynq/internal/base" "github.com/hibiken/asynq/internal/base"
"github.com/hibiken/asynq/internal/errors" "github.com/hibiken/asynq/internal/errors"
"github.com/hibiken/asynq/internal/log" "github.com/hibiken/asynq/internal/log"
"github.com/hibiken/asynq/internal/rdb" "github.com/hibiken/asynq/internal/rdb"
h "github.com/hibiken/asynq/internal/testutil"
"github.com/hibiken/asynq/internal/timeutil" "github.com/hibiken/asynq/internal/timeutil"
) )

View File

@ -10,9 +10,9 @@ import (
"time" "time"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
h "github.com/hibiken/asynq/internal/asynqtest"
"github.com/hibiken/asynq/internal/base" "github.com/hibiken/asynq/internal/base"
"github.com/hibiken/asynq/internal/rdb" "github.com/hibiken/asynq/internal/rdb"
h "github.com/hibiken/asynq/internal/testutil"
) )
func TestRecoverer(t *testing.T) { func TestRecoverer(t *testing.T) {

View File

@ -10,8 +10,8 @@ import (
"time" "time"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/hibiken/asynq/internal/asynqtest"
"github.com/hibiken/asynq/internal/base" "github.com/hibiken/asynq/internal/base"
"github.com/hibiken/asynq/internal/testutil"
) )
func TestSchedulerRegister(t *testing.T) { func TestSchedulerRegister(t *testing.T) {
@ -69,8 +69,8 @@ func TestSchedulerRegister(t *testing.T) {
time.Sleep(tc.wait) time.Sleep(tc.wait)
scheduler.Shutdown() scheduler.Shutdown()
got := asynqtest.GetPendingMessages(t, r, tc.queue) got := testutil.GetPendingMessages(t, r, tc.queue)
if diff := cmp.Diff(tc.want, got, asynqtest.IgnoreIDOpt); diff != "" { if diff := cmp.Diff(tc.want, got, testutil.IgnoreIDOpt); diff != "" {
t.Errorf("mismatch found in queue %q: (-want,+got)\n%s", tc.queue, diff) t.Errorf("mismatch found in queue %q: (-want,+got)\n%s", tc.queue, diff)
} }
} }
@ -148,7 +148,7 @@ func TestSchedulerUnregister(t *testing.T) {
time.Sleep(tc.wait) time.Sleep(tc.wait)
scheduler.Shutdown() scheduler.Shutdown()
got := asynqtest.GetPendingMessages(t, r, tc.queue) got := testutil.GetPendingMessages(t, r, tc.queue)
if len(got) != 0 { if len(got) != 0 {
t.Errorf("%d tasks were enqueued, want zero", len(got)) t.Errorf("%d tasks were enqueued, want zero", len(got))
} }

View File

@ -11,9 +11,9 @@ import (
"testing" "testing"
"time" "time"
"github.com/hibiken/asynq/internal/asynqtest"
"github.com/hibiken/asynq/internal/rdb" "github.com/hibiken/asynq/internal/rdb"
"github.com/hibiken/asynq/internal/testbroker" "github.com/hibiken/asynq/internal/testbroker"
"github.com/hibiken/asynq/internal/testutil"
"go.uber.org/goleak" "go.uber.org/goleak"
) )
@ -40,12 +40,12 @@ func TestServer(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
_, err = c.Enqueue(NewTask("send_email", asynqtest.JSON(map[string]interface{}{"recipient_id": 123}))) _, err = c.Enqueue(NewTask("send_email", testutil.JSON(map[string]interface{}{"recipient_id": 123})))
if err != nil { if err != nil {
t.Errorf("could not enqueue a task: %v", err) t.Errorf("could not enqueue a task: %v", err)
} }
_, err = c.Enqueue(NewTask("send_email", asynqtest.JSON(map[string]interface{}{"recipient_id": 456})), ProcessIn(1*time.Hour)) _, err = c.Enqueue(NewTask("send_email", testutil.JSON(map[string]interface{}{"recipient_id": 456})), ProcessIn(1*time.Hour))
if err != nil { if err != nil {
t.Errorf("could not enqueue a task: %v", err) t.Errorf("could not enqueue a task: %v", err)
} }

View File

@ -11,9 +11,9 @@ import (
"testing" "testing"
"time" "time"
h "github.com/hibiken/asynq/internal/asynqtest"
"github.com/hibiken/asynq/internal/base" "github.com/hibiken/asynq/internal/base"
"github.com/hibiken/asynq/internal/rdb" "github.com/hibiken/asynq/internal/rdb"
h "github.com/hibiken/asynq/internal/testutil"
) )
func TestSyncer(t *testing.T) { func TestSyncer(t *testing.T) {