mirror of
https://github.com/hibiken/asynq.git
synced 2024-11-10 11:31:58 +08:00
Fix flaky test
This commit is contained in:
parent
92d77bbc6e
commit
6978e93080
@ -6,6 +6,7 @@ package asynq
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -768,8 +769,12 @@ func TestInspectorKillAllScheduledTasks(t *testing.T) {
|
|||||||
t.Errorf("There are still %d entries in scheduled queue, want empty",
|
t.Errorf("There are still %d entries in scheduled queue, want empty",
|
||||||
len(gotScheduled))
|
len(gotScheduled))
|
||||||
}
|
}
|
||||||
|
// Allow Z.Score to differ by up to 2.
|
||||||
|
approxOpt := cmp.Comparer(func(a, b int64) bool {
|
||||||
|
return math.Abs(float64(a-b)) < 2
|
||||||
|
})
|
||||||
gotDead := asynqtest.GetDeadEntries(t, r)
|
gotDead := asynqtest.GetDeadEntries(t, r)
|
||||||
if diff := cmp.Diff(tc.wantDead, gotDead, asynqtest.SortZSetEntryOpt); diff != "" {
|
if diff := cmp.Diff(tc.wantDead, gotDead, asynqtest.SortZSetEntryOpt, approxOpt); diff != "" {
|
||||||
t.Errorf("mismatch in %q; (-want,+got)\n%s", base.DeadQueue, diff)
|
t.Errorf("mismatch in %q; (-want,+got)\n%s", base.DeadQueue, diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user