Skip to content

Commit

Permalink
chore: make rabbitmq examples more readable (#1905)
Browse files Browse the repository at this point in the history
* chore: add raw command implementation of Executable

* chore: make rabbitmq examples more readable
  • Loading branch information
mdelapenya authored Nov 6, 2023
1 parent cb8866c commit ef7e6bf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
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

0 comments on commit ef7e6bf

Please sign in to comment.