Skip to content

Commit 94e591a

Browse files
committed
refactor: refactor RabbitMQ connection handling and cleanup tests
- Remove unused `endpoint` variable in `TestShutdownWorkFlow` - Add retrieval of RabbitMQ container port and host - Replace RabbitMQ connection address with formatted host and port values - Remove unnecessary log statement Signed-off-by: appleboy <[email protected]>
1 parent 3b59d86 commit 94e591a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

rabbitmq_test.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,18 @@ func setupRabbitMQContainer(ctx context.Context, t *testing.T) (testcontainers.C
5959

6060
func TestShutdownWorkFlow(t *testing.T) {
6161
ctx := context.Background()
62-
rabbitMQC, endpoint := setupRabbitMQContainer(ctx, t)
62+
rabbitMQC, _ := setupRabbitMQContainer(ctx, t)
6363
defer testcontainers.CleanupContainer(t, rabbitMQC)
64-
log.Println("RabbitMQ endpoint:", endpoint)
64+
65+
port, err := rabbitMQC.MappedPort(ctx, "5672")
66+
assert.NoError(t, err)
67+
68+
host, err := rabbitMQC.Host(ctx)
69+
assert.NoError(t, err)
70+
6571
w := NewWorker(
6672
WithQueue("test"),
67-
WithAddr(fmt.Sprintf("amqp://guest:guest@%s/", endpoint)),
73+
WithAddr(fmt.Sprintf("amqp://guest:guest@%s:%s/", host, port.Port())),
6874
)
6975
q, err := queue.NewQueue(
7076
queue.WithWorker(w),

0 commit comments

Comments
 (0)