Skip to content

Commit 6fd28b6

Browse files
committed
refactor: refactor Redis host configuration
- Change the value of `host` variable to `127.0.0.1:6379` - Add `host01` variable with the value `127.0.0.1:6379` - Add `host02` variable with the value `127.0.0.1:6380` - Replace `WithAddr(host+":6379")` with `WithAddr(host01)` - Replace `WithAddr(host+":6379")` with `WithAddr(host01)` - Replace `WithAddr(host+":6379")` with `WithAddr(host01)` - Replace `hosts := []string{host + ":6379", host + ":6380"}` with `hosts := []string{host01, host02}` - Replace `hosts := []string{host + ":26379", host + ":26380"}` with `hosts := []string{"127.0.0.1:26379", "127.0.0.1:26380"}` - Replace `WithAddr(host+":6379")` with `WithAddr(host01)` - Replace `WithAddr(host+":6379")` with `WithAddr(host01)` - Replace `WithAddr(host+":6379")` with `WithAddr(host01)` - Replace `WithAddr(host+":6379")` with `WithAddr(host01)` - Replace `WithAddr(host+":6379")` with `WithAddr(host01)` Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 512db63 commit 6fd28b6

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

redis_test.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ import (
1818
"go.uber.org/goleak"
1919
)
2020

21-
var host = "127.0.0.1"
21+
var (
22+
host01 = "127.0.0.1:6379"
23+
host02 = "127.0.0.1:6380"
24+
)
2225

2326
func TestMain(m *testing.M) {
2427
goleak.VerifyTestMain(m)
@@ -37,7 +40,7 @@ func TestRedisDefaultFlow(t *testing.T) {
3740
Message: "foo",
3841
}
3942
w := NewWorker(
40-
WithAddr(host+":6379"),
43+
WithAddr(host01),
4144
WithChannel("test"),
4245
)
4346
q, err := queue.NewQueue(
@@ -56,7 +59,7 @@ func TestRedisDefaultFlow(t *testing.T) {
5659

5760
func TestRedisShutdown(t *testing.T) {
5861
w := NewWorker(
59-
WithAddr(host+":6379"),
62+
WithAddr(host01),
6063
WithChannel("test2"),
6164
)
6265
q, err := queue.NewQueue(
@@ -78,7 +81,7 @@ func TestCustomFuncAndWait(t *testing.T) {
7881
Message: "foo",
7982
}
8083
w := NewWorker(
81-
WithAddr(host+":6379"),
84+
WithAddr(host01),
8285
WithChannel("test3"),
8386
WithRunFunc(func(ctx context.Context, m core.QueuedMessage) error {
8487
time.Sleep(500 * time.Millisecond)
@@ -105,7 +108,7 @@ func TestRedisCluster(t *testing.T) {
105108
Message: "foo",
106109
}
107110

108-
hosts := []string{host + ":6379", host + ":6380"}
111+
hosts := []string{host01, host02}
109112

110113
w := NewWorker(
111114
WithAddr(strings.Join(hosts, ",")),
@@ -135,7 +138,7 @@ func TestRedisSentinel(t *testing.T) {
135138
m := &mockMessage{
136139
Message: "foo",
137140
}
138-
hosts := []string{host + ":26379", host + ":26380"}
141+
hosts := []string{"127.0.0.1:26379", "127.0.0.1:26380"}
139142

140143
w := NewWorker(
141144
WithAddr(strings.Join(hosts, ",")),
@@ -166,7 +169,7 @@ func TestEnqueueJobAfterShutdown(t *testing.T) {
166169
Message: "foo",
167170
}
168171
w := NewWorker(
169-
WithAddr(host + ":6379"),
172+
WithAddr(host01),
170173
)
171174
q, err := queue.NewQueue(
172175
queue.WithWorker(w),
@@ -188,7 +191,7 @@ func TestJobReachTimeout(t *testing.T) {
188191
Message: "foo",
189192
}
190193
w := NewWorker(
191-
WithAddr(host+":6379"),
194+
WithAddr(host01),
192195
WithChannel("timeout"),
193196
WithRunFunc(func(ctx context.Context, m core.QueuedMessage) error {
194197
for {
@@ -225,7 +228,7 @@ func TestCancelJobAfterShutdown(t *testing.T) {
225228
Message: "test",
226229
}
227230
w := NewWorker(
228-
WithAddr(host+":6379"),
231+
WithAddr(host01),
229232
WithChannel("cancel"),
230233
WithLogger(queue.NewLogger()),
231234
WithRunFunc(func(ctx context.Context, m core.QueuedMessage) error {
@@ -263,7 +266,7 @@ func TestGoroutineLeak(t *testing.T) {
263266
Message: "foo",
264267
}
265268
w := NewWorker(
266-
WithAddr(host+":6379"),
269+
WithAddr(host01),
267270
WithChannel("GoroutineLeak"),
268271
WithLogger(queue.NewEmptyLogger()),
269272
WithRunFunc(func(ctx context.Context, m core.QueuedMessage) error {
@@ -308,7 +311,7 @@ func TestGoroutinePanic(t *testing.T) {
308311
Message: "foo",
309312
}
310313
w := NewWorker(
311-
WithAddr(host+":6379"),
314+
WithAddr(host01),
312315
WithChannel("GoroutinePanic"),
313316
WithRunFunc(func(ctx context.Context, m core.QueuedMessage) error {
314317
panic("missing something")

0 commit comments

Comments
 (0)