|
5 | 5 | "context" |
6 | 6 | "strings" |
7 | 7 | "testing" |
| 8 | + "time" |
8 | 9 |
|
9 | 10 | "github.com/nats-io/nats.go" |
10 | 11 | "github.com/stretchr/testify/require" |
@@ -78,21 +79,23 @@ authorization { |
78 | 79 |
|
79 | 80 | // connect without a correct token must fail |
80 | 81 | mallory, err := nats.Connect(uri, nats.Name("Mallory"), nats.Token("secret")) |
81 | | - require.Error(t, err) |
82 | | - require.ErrorIs(t, err, nats.ErrAuthorization) |
83 | 82 | t.Cleanup(mallory.Close) |
| 83 | + require.EqualError(t, err, "nats: Authorization Violation") |
84 | 84 |
|
85 | 85 | // connect with a correct token must succeed |
86 | 86 | nc, err := nats.Connect(uri, nats.Name("API Token Test"), nats.Token("s3cr3t")) |
87 | | - require.NoError(t, err) |
88 | 87 | t.Cleanup(nc.Close) |
| 88 | + require.NoError(t, err) |
89 | 89 |
|
90 | 90 | // validate /etc/nats.conf mentioned in logs |
91 | 91 | const expected = "Using configuration file: /etc/nats.conf" |
92 | 92 | logs, err := ctr.Logs(ctx) |
93 | 93 | require.NoError(t, err) |
94 | 94 | sc := bufio.NewScanner(logs) |
95 | 95 | 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 | + }) |
96 | 99 | for sc.Scan() { |
97 | 100 | if strings.Contains(sc.Text(), expected) { |
98 | 101 | found = true |
|
0 commit comments