-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathredis_test.go
More file actions
37 lines (28 loc) · 770 Bytes
/
redis_test.go
File metadata and controls
37 lines (28 loc) · 770 Bytes
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
package redisqueue
import (
"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().Err()
assert.NoError(tt, err)
})
t.Run("defaults options if it's nil", func(tt *testing.T) {
r := newRedisClient(nil)
err := r.Ping().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")
})
}