forked from hibiken/asynq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
asynq_test.go
42 lines (35 loc) · 919 Bytes
/
asynq_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2020 Kentaro Hibino. All rights reserved.
// Use of this source code is governed by a MIT license
// that can be found in the LICENSE file.
package asynq
import (
"sort"
"testing"
"github.com/go-redis/redis/v7"
"github.com/google/go-cmp/cmp"
h "github.com/hibiken/asynq/internal/asynqtest"
)
// This file defines test helper functions used by
// other test files.
// redis used for package testing.
const (
redisAddr = "localhost:6379"
redisDB = 14
)
func setup(tb testing.TB) *redis.Client {
tb.Helper()
r := redis.NewClient(&redis.Options{
Addr: redisAddr,
DB: redisDB,
})
// Start each test with a clean slate.
h.FlushDB(tb, r)
return r
}
var sortTaskOpt = cmp.Transformer("SortMsg", func(in []*Task) []*Task {
out := append([]*Task(nil), in...) // Copy input to avoid mutating it
sort.Slice(out, func(i, j int) bool {
return out[i].Type < out[j].Type
})
return out
})