Skip to content

Commit

Permalink
refactor: refactor Redis host configuration
Browse files Browse the repository at this point in the history
- 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]>
  • Loading branch information
appleboy committed Dec 5, 2023
1 parent 512db63 commit 6fd28b6
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import (
"go.uber.org/goleak"
)

var host = "127.0.0.1"
var (
host01 = "127.0.0.1:6379"
host02 = "127.0.0.1:6380"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
Expand All @@ -37,7 +40,7 @@ func TestRedisDefaultFlow(t *testing.T) {
Message: "foo",
}
w := NewWorker(
WithAddr(host+":6379"),
WithAddr(host01),
WithChannel("test"),
)
q, err := queue.NewQueue(
Expand All @@ -56,7 +59,7 @@ func TestRedisDefaultFlow(t *testing.T) {

func TestRedisShutdown(t *testing.T) {
w := NewWorker(
WithAddr(host+":6379"),
WithAddr(host01),
WithChannel("test2"),
)
q, err := queue.NewQueue(
Expand All @@ -78,7 +81,7 @@ func TestCustomFuncAndWait(t *testing.T) {
Message: "foo",
}
w := NewWorker(
WithAddr(host+":6379"),
WithAddr(host01),
WithChannel("test3"),
WithRunFunc(func(ctx context.Context, m core.QueuedMessage) error {
time.Sleep(500 * time.Millisecond)
Expand All @@ -105,7 +108,7 @@ func TestRedisCluster(t *testing.T) {
Message: "foo",
}

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

w := NewWorker(
WithAddr(strings.Join(hosts, ",")),
Expand Down Expand Up @@ -135,7 +138,7 @@ func TestRedisSentinel(t *testing.T) {
m := &mockMessage{
Message: "foo",
}
hosts := []string{host + ":26379", host + ":26380"}
hosts := []string{"127.0.0.1:26379", "127.0.0.1:26380"}

w := NewWorker(
WithAddr(strings.Join(hosts, ",")),
Expand Down Expand Up @@ -166,7 +169,7 @@ func TestEnqueueJobAfterShutdown(t *testing.T) {
Message: "foo",
}
w := NewWorker(
WithAddr(host + ":6379"),
WithAddr(host01),
)
q, err := queue.NewQueue(
queue.WithWorker(w),
Expand All @@ -188,7 +191,7 @@ func TestJobReachTimeout(t *testing.T) {
Message: "foo",
}
w := NewWorker(
WithAddr(host+":6379"),
WithAddr(host01),
WithChannel("timeout"),
WithRunFunc(func(ctx context.Context, m core.QueuedMessage) error {
for {
Expand Down Expand Up @@ -225,7 +228,7 @@ func TestCancelJobAfterShutdown(t *testing.T) {
Message: "test",
}
w := NewWorker(
WithAddr(host+":6379"),
WithAddr(host01),
WithChannel("cancel"),
WithLogger(queue.NewLogger()),
WithRunFunc(func(ctx context.Context, m core.QueuedMessage) error {
Expand Down Expand Up @@ -263,7 +266,7 @@ func TestGoroutineLeak(t *testing.T) {
Message: "foo",
}
w := NewWorker(
WithAddr(host+":6379"),
WithAddr(host01),
WithChannel("GoroutineLeak"),
WithLogger(queue.NewEmptyLogger()),
WithRunFunc(func(ctx context.Context, m core.QueuedMessage) error {
Expand Down Expand Up @@ -308,7 +311,7 @@ func TestGoroutinePanic(t *testing.T) {
Message: "foo",
}
w := NewWorker(
WithAddr(host+":6379"),
WithAddr(host01),
WithChannel("GoroutinePanic"),
WithRunFunc(func(ctx context.Context, m core.QueuedMessage) error {
panic("missing something")
Expand Down

0 comments on commit 6fd28b6

Please sign in to comment.