From ef7e6bfcd0d778a4494f2bbbab6de50a7b7e6cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Mon, 6 Nov 2023 14:17:33 +0100 Subject: [PATCH] chore: make rabbitmq examples more readable (#1905) * chore: add raw command implementation of Executable * chore: make rabbitmq examples more readable --- modules/rabbitmq/examples_test.go | 5 +++-- modules/rabbitmq/types_test.go | 1 + options.go | 8 ++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/rabbitmq/examples_test.go b/modules/rabbitmq/examples_test.go index 47edfb27c9..d239bc1f3a 100644 --- a/modules/rabbitmq/examples_test.go +++ b/modules/rabbitmq/examples_test.go @@ -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) diff --git a/modules/rabbitmq/types_test.go b/modules/rabbitmq/types_test.go index fec1990a72..ca9fed49d4 100644 --- a/modules/rabbitmq/types_test.go +++ b/modules/rabbitmq/types_test.go @@ -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 --------- diff --git a/options.go b/options.go index 3b2e2de262..0e15fc9080 100644 --- a/options.go +++ b/options.go @@ -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.