diff --git a/scheduler_test.go b/scheduler_test.go index 9078ed0..ed052b1 100644 --- a/scheduler_test.go +++ b/scheduler_test.go @@ -209,7 +209,7 @@ func TestSchedulerPostAndPreEnqueueHandler(t *testing.T) { postMu.Unlock() } -func TestSchedulerWithCustomEntryIDGeneratorFunc(t *testing.T) { +func TestSchedulerWithCustomEntryIDOpt(t *testing.T) { tests := []struct { cronspec string task *Task @@ -221,7 +221,8 @@ func TestSchedulerWithCustomEntryIDGeneratorFunc(t *testing.T) { { cronspec: "@every 3s", task: NewTask("task1", nil), - opts: []Option{MaxRetry(10), + opts: []Option{ + MaxRetry(10), SchedulerEntryID("entry1"), }, wait: 10 * time.Second, @@ -235,43 +236,22 @@ func TestSchedulerWithCustomEntryIDGeneratorFunc(t *testing.T) { Queue: "default", ID: "entry1", }, - { - Type: "task1", - Payload: nil, - Retry: 10, - Timeout: int64(defaultTimeout.Seconds()), - Queue: "default", - ID: "entry1", - }, - { - Type: "task1", - Payload: nil, - Retry: 10, - Timeout: int64(defaultTimeout.Seconds()), - Queue: "default", - ID: "entry1", - }, }, }, } - r := setup(t) - for _, tc := range tests { scheduler := NewScheduler(getRedisConnOpt(t), nil) - if _, err := scheduler.Register(tc.cronspec, tc.task, tc.opts...); err != nil { + entryID, err := scheduler.Register(tc.cronspec, tc.task, tc.opts...) + if err != nil { t.Fatal(err) } - if err := scheduler.Start(); err != nil { - t.Fatal(err) - } time.Sleep(tc.wait) scheduler.Shutdown() - got := testutil.GetPendingMessages(t, r, tc.queue) - if diff := cmp.Diff(tc.want, got, testutil.IgnoreIDOpt); diff != "" { - t.Errorf("mismatch found in queue %q: (-want,+got)\n%s", tc.queue, diff) + if entryID != "entry1" { + t.Errorf("entryID = %q, want %q", entryID, "entry1") } } }