diff --git a/processor_test.go b/processor_test.go index 9ecb8fe..da1b577 100644 --- a/processor_test.go +++ b/processor_test.go @@ -104,12 +104,14 @@ func TestProcessorSuccess(t *testing.T) { t.Fatal(err) } } - time.Sleep(time.Second) // wait for one second to allow all enqueued tasks to be processed. + time.Sleep(2 * time.Second) // wait for two second to allow all enqueued tasks to be processed. p.terminate() + mu.Lock() if diff := cmp.Diff(tc.wantProcessed, processed, sortTaskOpt, cmp.AllowUnexported(Payload{})); diff != "" { t.Errorf("mismatch found in processed tasks; (-want, +got)\n%s", diff) } + mu.Unlock() if l := r.LLen(base.InProgressQueue).Val(); l != 0 { t.Errorf("%q has %d tasks, want 0", base.InProgressQueue, l) @@ -160,7 +162,7 @@ func TestProcessorRetry(t *testing.T) { handler: HandlerFunc(func(ctx context.Context, task *Task) error { return fmt.Errorf(errMsg) }), - wait: time.Second, + wait: 2 * time.Second, wantRetry: []h.ZSetEntry{ {Msg: &r2, Score: float64(now.Add(time.Minute).Unix())}, {Msg: &r3, Score: float64(now.Add(time.Minute).Unix())}, @@ -217,7 +219,7 @@ func TestProcessorRetry(t *testing.T) { t.Fatal(err) } } - time.Sleep(tc.wait) + time.Sleep(tc.wait) // FIXME: This makes test flaky. p.terminate() cmpOpt := cmpopts.EquateApprox(0, float64(time.Second)) // allow up to a second difference in zset score