mirror of
https://github.com/hibiken/asynq.git
synced 2025-10-23 10:16:12 +08:00
Fix flaky ProcessorRetry test
This commit is contained in:
@@ -7,6 +7,7 @@ package asynqtest
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"math"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
@@ -17,6 +18,14 @@ import (
|
||||
"github.com/hibiken/asynq/internal/base"
|
||||
)
|
||||
|
||||
// EquateInt64Approx returns a Comparer option that treats int64 values
|
||||
// to be equal if they are within the given margin.
|
||||
func EquateInt64Approx(margin int64) cmp.Option {
|
||||
return cmp.Comparer(func(a, b int64) bool {
|
||||
return math.Abs(float64(a-b)) < float64(margin)
|
||||
})
|
||||
}
|
||||
|
||||
// SortMsgOpt is a cmp.Option to sort base.TaskMessage for comparing slice of task messages.
|
||||
var SortMsgOpt = cmp.Transformer("SortTaskMessages", func(in []*base.TaskMessage) []*base.TaskMessage {
|
||||
out := append([]*base.TaskMessage(nil), in...) // Copy input to avoid mutating it
|
||||
|
Reference in New Issue
Block a user