Skip to content

Commit ff17ba1

Browse files
committed
address CR comments
1 parent a599cae commit ff17ba1

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

docs/modules/nats.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ These arguments are passed to the NATS server when it starts, as part of the com
7979
8080
- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>
8181
82-
It's possible to pass a custom config file to NATS container using `nats.WithConfigFile(strings.NewReader(config))`. The `io.Reader` is passed as a `-config /etc/nats.conf` arguments to an entrypoint.
82+
It's possible to pass a custom config file to NATS container using `nats.WithConfigFile(strings.NewReader(config))`. The content of `io.Reader` is passed as a `-config /etc/nats.conf` arguments to an entrypoint.
8383

8484
!!! note
8585
Changing the connectivity (listen address or ports) can break the container setup. So configuration must be done with care.

modules/nats/nats_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"strings"
77
"testing"
8+
"time"
89

910
"github.com/nats-io/nats.go"
1011
"github.com/stretchr/testify/require"
@@ -78,21 +79,23 @@ authorization {
7879

7980
// connect without a correct token must fail
8081
mallory, err := nats.Connect(uri, nats.Name("Mallory"), nats.Token("secret"))
81-
require.Error(t, err)
82-
require.ErrorIs(t, err, nats.ErrAuthorization)
8382
t.Cleanup(mallory.Close)
83+
require.EqualError(t, err, "nats: Authorization Violation")
8484

8585
// connect with a correct token must succeed
8686
nc, err := nats.Connect(uri, nats.Name("API Token Test"), nats.Token("s3cr3t"))
87-
require.NoError(t, err)
8887
t.Cleanup(nc.Close)
88+
require.NoError(t, err)
8989

9090
// validate /etc/nats.conf mentioned in logs
9191
const expected = "Using configuration file: /etc/nats.conf"
9292
logs, err := ctr.Logs(ctx)
9393
require.NoError(t, err)
9494
sc := bufio.NewScanner(logs)
9595
found := false
96+
time.AfterFunc(5*time.Second, func() {
97+
require.Truef(t, found, "expected log line not found after 5 seconds: %s", expected)
98+
})
9699
for sc.Scan() {
97100
if strings.Contains(sc.Text(), expected) {
98101
found = true

0 commit comments

Comments
 (0)