Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make rabbitmq examples more readable #1905

Merged
merged 2 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions modules/rabbitmq/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ func ExampleRunContainer_withPlugins() {

rabbitmqContainer, err := rabbitmq.RunContainer(ctx,
testcontainers.WithImage("rabbitmq:3.7.25-management-alpine"),
// Plugin is a test implementation of an Executable, please check types_test.go file for more details
testcontainers.WithStartupCommand(Plugin("rabbitmq_shovel"), Plugin("rabbitmq_random_exchange")),
// Multiple test implementations of the Executable interface, specific to RabbitMQ, exist in the types_test.go file.
// Please refer to them for more examples.
testcontainers.WithStartupCommand(testcontainers.RawCommand{"rabbitmq_shovel"}, testcontainers.RawCommand{"rabbitmq_random_exchange"}),
)
if err != nil {
panic(err)
Expand Down
1 change: 1 addition & 0 deletions modules/rabbitmq/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
// they are not used in the RabbitMQ module.
// All of them implement the testcontainers.Executable interface, which is used to generate
// the command that will be executed, with the "AsCommand" method.
// Please be aware that they could be outdated, as they are not actively maintained, just here for reference.

// --------- Bindings ---------

Expand Down
8 changes: 8 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ type Executable interface {
AsCommand() []string
}

// RawCommand is a type that implements Executable and represents a command to be sent to a container
type RawCommand []string

// AsCommand returns the command as a slice of strings
func (r RawCommand) AsCommand() []string {
return r
}

// WithStartupCommand will execute the command representation of each Executable into the container.
// It will leverage the container lifecycle hooks to call the command right after the container
// is started.
Expand Down
Loading