-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathredis_test.go
143 lines (97 loc) · 3.28 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package fridge
import (
"crypto/tls"
"github.com/stretchr/testify/assert"
"testing"
"time"
)
func TestRedisClient_WithHost(t *testing.T) {
redisSettings := &RedisSettings{}
redisOption := WithHost("host")
redisOption(redisSettings)
assert.Equal(t, redisSettings.Host, "host")
}
func TestRedisClient_WithPort(t *testing.T) {
redisSettings := &RedisSettings{}
redisOption := WithPort(1111)
redisOption(redisSettings)
assert.Equal(t, redisSettings.Port, 1111)
}
func TestRedisClient_WithPassword(t *testing.T) {
redisSettings := &RedisSettings{}
redisOption := WithPassword("password")
redisOption(redisSettings)
assert.Equal(t, redisSettings.Password, "password")
}
func TestRedisClient_WithDatabase(t *testing.T) {
redisSettings := &RedisSettings{}
redisOption := WithDatabase(1)
redisOption(redisSettings)
assert.Equal(t, redisSettings.Database, 1)
}
func TestRedisClient_WithNetwork(t *testing.T) {
redisSettings := &RedisSettings{}
redisOption := WithNetwork("network")
redisOption(redisSettings)
assert.Equal(t, redisSettings.Network, "network")
}
func TestRedisClient_WithConnectTimeout(t *testing.T) {
redisSettings := &RedisSettings{}
redisOption := WithConnectTimeout(time.Second)
redisOption(redisSettings)
assert.Equal(t, redisSettings.ConnectTimeout, time.Second)
}
func TestRedisClient_WithReadTimeout(t *testing.T) {
redisSettings := &RedisSettings{}
redisOption := WithReadTimeout(time.Second)
redisOption(redisSettings)
assert.Equal(t, redisSettings.ReadTimeout, time.Second)
}
func TestRedisClient_WithWriteTimeout(t *testing.T) {
redisSettings := &RedisSettings{}
redisOption := WithWriteTimeout(time.Second)
redisOption(redisSettings)
assert.Equal(t, redisSettings.WriteTimeout, time.Second)
}
func TestRedisClient_WithConnectionIdleTimeout(t *testing.T) {
redisSettings := &RedisSettings{}
redisOption := WithConnectionIdleTimeout(time.Second)
redisOption(redisSettings)
assert.Equal(t, redisSettings.ConnectionIdleTimeout, time.Second)
}
func TestRedisClient_WithConnectionMaxIdle(t *testing.T) {
redisSettings := &RedisSettings{}
redisOption := WithConnectionMaxIdle(11)
redisOption(redisSettings)
assert.Equal(t, redisSettings.ConnectionMaxIdle, 11)
}
func TestRedisClient_WithConnectionMaxActive(t *testing.T) {
redisSettings := &RedisSettings{}
redisOption := WithConnectionMaxActive(11)
redisOption(redisSettings)
assert.Equal(t, redisSettings.ConnectionMaxActive, 11)
}
func TestRedisClient_WithConnectionWait(t *testing.T) {
redisSettings := &RedisSettings{}
redisOption := WithConnectionWait(true)
redisOption(redisSettings)
assert.Equal(t, redisSettings.ConnectionWait, true)
}
func TestRedisClient_WithTlsConfig(t *testing.T) {
redisSettings := &RedisSettings{}
redisOption := WithTlsConfig(&tls.Config{})
redisOption(redisSettings)
assert.NotNil(t, redisSettings.TlsConfig)
}
func TestRedisClient_WithTlsSkipVerify(t *testing.T) {
redisSettings := &RedisSettings{}
redisOption := WithTlsSkipVerify(true)
redisOption(redisSettings)
assert.Equal(t, redisSettings.TlsSkipVerify, true)
}
func TestRedisClient_WithTestOnBorrowPeriod(t *testing.T) {
redisSettings := &RedisSettings{}
redisOption := WithTestOnBorrowPeriod(time.Second)
redisOption(redisSettings)
assert.Equal(t, redisSettings.TestOnBorrowPeriod, time.Second)
}