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

docs: embed code snippets for the artemis module #1502

Merged
merged 1 commit into from
Aug 14, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 21 additions & 21 deletions docs/modules/artemis.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
```
<!--codeinclude-->
[With credentials](../../modules/artemis/artemis_test.go) inside_block:withCredentials
<!--/codeinclude-->

#### Anonymous Login

If you need to enable anonymous logins (which are disabled by default) use `WithAnonymousLogin`.

```go
container, err := artemis.RunContainer(ctx, artemis.WithAnonymousLogin())
```
<!--codeinclude-->
[With Anonymous Login](../../modules/artemis/artemis_test.go) inside_block:withAnonymousLogin
<!--/codeinclude-->

#### Custom Arguments

Expand All @@ -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"))
```
<!--codeinclude-->
[With Extra Arguments](../../modules/artemis/artemis_test.go) inside_block:withExtraArgs
<!--/codeinclude-->

#### Docker type modifiers

Expand All @@ -95,30 +95,30 @@ The Artemis container exposes the following methods:

User returns the administrator username.

```go
user := container.User()
```
<!--codeinclude-->
[Retrieving the Administrator User](../../modules/artemis/example_test.go) inside_block:containerUser
<!--/codeinclude-->

#### Password

Password returns the administrator password.

```go
password := container.Password()
```
<!--codeinclude-->
[Retrieving the Administrator Password](../../modules/artemis/example_test.go) inside_block:containerPassword
<!--/codeinclude-->

#### BrokerEndpoint

BrokerEndpoint returns the host:port for the combined protocols endpoint.

```go
host, err := container.BrokerEndpoint(ctx)
```
<!--codeinclude-->
[Get broker endpoint](../../modules/artemis/artemis_test.go) inside_block:brokerEndpoint
<!--/codeinclude-->

#### ConsoleURL

ConsoleURL returns the URL for the management console.

```go
url, err := container.ConsoleURL(ctx)
```
<!--codeinclude-->
[Get console URL](../../modules/artemis/artemis_test.go) inside_block:consoleURL
<!--/codeinclude-->
10 changes: 10 additions & 0 deletions modules/artemis/artemis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,27 @@ func TestArtemis(t *testing.T) {
{
name: "WithCredentials",
opts: []testcontainers.ContainerCustomizer{
// withCredentials {
artemis.WithCredentials("test", "test"),
// }
},
user: "test",
pass: "test",
},
{
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",
Expand All @@ -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)
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions modules/artemis/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down