Skip to content

Commit

Permalink
test: update image tag & add test with default options
Browse files Browse the repository at this point in the history
  • Loading branch information
abemedia committed Jan 11, 2024
1 parent ae6a3e7 commit 263fa38
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/rabbitmq/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func ExampleRunContainer() {
ctx := context.Background()

rabbitmqContainer, err := rabbitmq.RunContainer(ctx,
testcontainers.WithImage("rabbitmq:3.7.25-management-alpine"),
testcontainers.WithImage("rabbitmq:3.12.11-management-alpine"),
rabbitmq.WithAdminUsername("admin"),
rabbitmq.WithAdminPassword("password"),
)
Expand Down
33 changes: 32 additions & 1 deletion modules/rabbitmq/rabbitmq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,46 @@ import (
"strings"
"testing"

amqp "github.com/rabbitmq/amqp091-go"

"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/rabbitmq"
)

func TestRunContainer_connectUsingAmqp(t *testing.T) {
ctx := context.Background()

rabbitmqContainer, err := rabbitmq.RunContainer(ctx)
if err != nil {
t.Fatal(err)
}

defer func() {
if err := rabbitmqContainer.Terminate(ctx); err != nil {
t.Fatal(err)
}
}()

amqpURL, err := rabbitmqContainer.AmqpURL(ctx)
if err != nil {
t.Fatal(err)
}

amqpConnection, err := amqp.Dial(amqpURL)
if err != nil {
t.Fatal(err)
}

if err = amqpConnection.Close(); err != nil {
t.Fatal(err)
}
}

func TestRunContainer_withAllSettings(t *testing.T) {
ctx := context.Background()

rabbitmqContainer, err := rabbitmq.RunContainer(ctx,
testcontainers.WithImage("rabbitmq:3.7.25-management-alpine"),
testcontainers.WithImage("rabbitmq:3.12.11-management-alpine"),
// addVirtualHosts {
testcontainers.WithStartupCommand(VirtualHost{Name: "vhost1"}),
testcontainers.WithStartupCommand(VirtualHostLimit{VHost: "vhost1", Name: "max-connections", Value: 1}),
Expand Down

0 comments on commit 263fa38

Please sign in to comment.