Fix flaky tests

Some tests were failing due to mismatch in Score in ZSetEntry.
Changed ZSetEntry Score to float64 type so that we can use
cmpopts.EquateApprox to allow for margin when comparing.
This commit is contained in:
Ken Hibino
2020-01-11 10:02:13 -08:00
parent 2631672575
commit 97316d6766
6 changed files with 152 additions and 150 deletions

View File

@@ -20,7 +20,7 @@ import (
// ZSetEntry is an entry in redis sorted set.
type ZSetEntry struct {
Msg *base.TaskMessage
Score int64
Score float64
}
// SortMsgOpt is a cmp.Option to sort base.TaskMessage for comparing slice of task messages.
@@ -245,7 +245,7 @@ func getZSetEntries(tb testing.TB, r *redis.Client, zset string) []ZSetEntry {
for _, z := range data {
entries = append(entries, ZSetEntry{
Msg: MustUnmarshal(tb, z.Member.(string)),
Score: int64(z.Score),
Score: z.Score,
})
}
return entries