forked from robinjoseph08/redisqueue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathredis_test.go
38 lines (29 loc) · 821 Bytes
/
redis_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
package redisqueue
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestNewRedisClient(t *testing.T) {
t.Run("returns a new redis client", func(tt *testing.T) {
options := &RedisOptions{}
r := newRedisClient(options)
err := r.Ping(context.Background()).Err()
assert.NoError(tt, err)
})
t.Run("defaults options if it's nil", func(tt *testing.T) {
r := newRedisClient(nil)
err := r.Ping(context.Background()).Err()
assert.NoError(tt, err)
})
}
func TestRedisPreflightChecks(t *testing.T) {
t.Run("bubbles up errors", func(tt *testing.T) {
options := &RedisOptions{Addr: "localhost:0"}
r := newRedisClient(options)
err := redisPreflightChecks(r)
require.Error(tt, err)
assert.Contains(tt, err.Error(), "dial tcp")
})
}