mirror of
https://github.com/hibiken/asynq.git
synced 2025-09-19 05:17:30 +08:00
Update NewTask function to take Option as varargs
This commit is contained in:
@@ -608,16 +608,17 @@ func TestClientEnqueueError(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientDefaultOptions(t *testing.T) {
|
||||
func TestClientWithDefaultOptions(t *testing.T) {
|
||||
r := setup(t)
|
||||
|
||||
now := time.Now()
|
||||
|
||||
tests := []struct {
|
||||
desc string
|
||||
defaultOpts []Option // options set at the client level.
|
||||
defaultOpts []Option // options set at task initialization time
|
||||
opts []Option // options used at enqueue time.
|
||||
task *Task
|
||||
tasktype string
|
||||
payload []byte
|
||||
wantInfo *TaskInfo
|
||||
queue string // queue that the message should go into.
|
||||
want *base.TaskMessage
|
||||
@@ -626,7 +627,8 @@ func TestClientDefaultOptions(t *testing.T) {
|
||||
desc: "With queue routing option",
|
||||
defaultOpts: []Option{Queue("feed")},
|
||||
opts: []Option{},
|
||||
task: NewTask("feed:import", nil),
|
||||
tasktype: "feed:import",
|
||||
payload: nil,
|
||||
wantInfo: &TaskInfo{
|
||||
Queue: "feed",
|
||||
Type: "feed:import",
|
||||
@@ -654,7 +656,8 @@ func TestClientDefaultOptions(t *testing.T) {
|
||||
desc: "With multiple options",
|
||||
defaultOpts: []Option{Queue("feed"), MaxRetry(5)},
|
||||
opts: []Option{},
|
||||
task: NewTask("feed:import", nil),
|
||||
tasktype: "feed:import",
|
||||
payload: nil,
|
||||
wantInfo: &TaskInfo{
|
||||
Queue: "feed",
|
||||
Type: "feed:import",
|
||||
@@ -682,7 +685,8 @@ func TestClientDefaultOptions(t *testing.T) {
|
||||
desc: "With overriding options at enqueue time",
|
||||
defaultOpts: []Option{Queue("feed"), MaxRetry(5)},
|
||||
opts: []Option{Queue("critical")},
|
||||
task: NewTask("feed:import", nil),
|
||||
tasktype: "feed:import",
|
||||
payload: nil,
|
||||
wantInfo: &TaskInfo{
|
||||
Queue: "critical",
|
||||
Type: "feed:import",
|
||||
@@ -711,8 +715,8 @@ func TestClientDefaultOptions(t *testing.T) {
|
||||
h.FlushDB(t, r)
|
||||
c := NewClient(getRedisConnOpt(t))
|
||||
defer c.Close()
|
||||
c.SetDefaultOptions(tc.task.Type(), tc.defaultOpts...)
|
||||
gotInfo, err := c.Enqueue(tc.task, tc.opts...)
|
||||
task := NewTask(tc.tasktype, tc.payload, tc.defaultOpts...)
|
||||
gotInfo, err := c.Enqueue(task, tc.opts...)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user