From 584db276e86911697c03b25349ac6a29e5ff2976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Mon, 14 Aug 2023 13:54:59 +0200 Subject: [PATCH] docs: embed code snippets for the artemis module --- docs/modules/artemis.md | 42 ++++++++++++++++----------------- modules/artemis/artemis_test.go | 10 ++++++++ modules/artemis/example_test.go | 4 ++++ 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/docs/modules/artemis.md b/docs/modules/artemis.md index 4a87a254ca..2f57cf3d00 100644 --- a/docs/modules/artemis.md +++ b/docs/modules/artemis.md @@ -54,17 +54,17 @@ At the same time, it's possible to set a wait strategy and a custom deadline wit If you need to change the default admin credentials (i.e. `artemis:artemis`) use `WithCredentials`. -```go -container, err := artemis.RunContainer(ctx, artemis.WithCredentials("user", "password")) -``` + +[With credentials](../../modules/artemis/artemis_test.go) inside_block:withCredentials + #### Anonymous Login If you need to enable anonymous logins (which are disabled by default) use `WithAnonymousLogin`. -```go -container, err := artemis.RunContainer(ctx, artemis.WithAnonymousLogin()) -``` + +[With Anonymous Login](../../modules/artemis/artemis_test.go) inside_block:withAnonymousLogin + #### Custom Arguments @@ -73,9 +73,9 @@ The default is `--http-host 0.0.0.0 --relax-jolokia`. Setting this value will override the default. See the documentation on `artemis create` for available options. -```go -container, err := artemis.RunContainer(ctx, artemis.WithExtraArgs("--http-host 0.0.0.0 --relax-jolokia --queues ArgsTestQueue")) -``` + +[With Extra Arguments](../../modules/artemis/artemis_test.go) inside_block:withExtraArgs + #### Docker type modifiers @@ -95,30 +95,30 @@ The Artemis container exposes the following methods: User returns the administrator username. -```go -user := container.User() -``` + +[Retrieving the Administrator User](../../modules/artemis/example_test.go) inside_block:containerUser + #### Password Password returns the administrator password. -```go -password := container.Password() -``` + +[Retrieving the Administrator Password](../../modules/artemis/example_test.go) inside_block:containerPassword + #### BrokerEndpoint BrokerEndpoint returns the host:port for the combined protocols endpoint. -```go -host, err := container.BrokerEndpoint(ctx) -``` + +[Get broker endpoint](../../modules/artemis/artemis_test.go) inside_block:brokerEndpoint + #### ConsoleURL ConsoleURL returns the URL for the management console. -```go -url, err := container.ConsoleURL(ctx) -``` + +[Get console URL](../../modules/artemis/artemis_test.go) inside_block:consoleURL + diff --git a/modules/artemis/artemis_test.go b/modules/artemis/artemis_test.go index 200d0a8439..b68fac3f21 100644 --- a/modules/artemis/artemis_test.go +++ b/modules/artemis/artemis_test.go @@ -31,7 +31,9 @@ func TestArtemis(t *testing.T) { { name: "WithCredentials", opts: []testcontainers.ContainerCustomizer{ + // withCredentials { artemis.WithCredentials("test", "test"), + // } }, user: "test", pass: "test", @@ -39,13 +41,17 @@ func TestArtemis(t *testing.T) { { name: "WithAnonymous", opts: []testcontainers.ContainerCustomizer{ + // withAnonymousLogin { artemis.WithAnonymousLogin(), + // } }, }, { name: "WithExtraArgs", opts: []testcontainers.ContainerCustomizer{ + // withExtraArgs { artemis.WithExtraArgs("--http-host 0.0.0.0 --relax-jolokia --queues ArgsTestQueue"), + // } }, user: "artemis", pass: "artemis", @@ -61,7 +67,9 @@ func TestArtemis(t *testing.T) { require.NoError(t, err) t.Cleanup(func() { require.NoError(t, container.Terminate(ctx), "failed to terminate container") }) + // consoleURL { u, err := container.ConsoleURL(ctx) + // } require.NoError(t, err) res, err := http.Get(u) @@ -77,7 +85,9 @@ func TestArtemis(t *testing.T) { assert.Equal(t, test.pass, container.Password(), "unexpected password") } + // brokerEndpoint { host, err := container.BrokerEndpoint(ctx) + // } require.NoError(t, err) var opt []func(*stomp.Conn) error diff --git a/modules/artemis/example_test.go b/modules/artemis/example_test.go index 5ff7679cac..b626056731 100644 --- a/modules/artemis/example_test.go +++ b/modules/artemis/example_test.go @@ -28,8 +28,12 @@ func ExampleRunContainer() { } // Get credentials. + // containerUser { user := container.User() + // } + // containerPassword { pass := container.Password() + // } // Connect to Artemis via STOMP. conn, err := stomp.Dial("tcp", host, stomp.ConnOpt.Login(user, pass))