Skip to content

Commit

Permalink
remove document markers from a unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
vyskocilm committed Dec 2, 2024
1 parent 03a0d09 commit 554f949
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions modules/nats/nats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,25 @@ authorization {
`
ctx := context.Background()

// createNATSContainer {
ctr, err := tcnats.Run(ctx, "nats:2.9", tcnats.WithConfigFile(strings.NewReader(natsConf)))
// }
testcontainers.CleanupContainer(t, ctr)
require.NoError(t, err)

// connectionString {
uri, err := ctr.ConnectionString(ctx)
// }
require.NoError(t, err)

// connect without token {
// connect without a correct token must fail
mallory, err := nats.Connect(uri, nats.Name("Mallory"), nats.Token("secret"))
// }
require.Error(t, err)
require.ErrorIs(t, err, nats.ErrAuthorization)
t.Cleanup(mallory.Close)

// connect via token {
// connect with a correct token must succeed
nc, err := nats.Connect(uri, nats.Name("API Token Test"), nats.Token("s3cr3t"))
// }
require.NoError(t, err)
t.Cleanup(nc.Close)

// validate /etc/nats.conf mentioned in logs {
// validate /etc/nats.conf mentioned in logs
const expected = "Using configuration file: /etc/nats.conf"
logs, err := ctr.Logs(ctx)
require.NoError(t, err)
Expand All @@ -105,6 +99,5 @@ authorization {
break
}
}
// }
require.Truef(t, found, "expected log line not found: %s", expected)
}

0 comments on commit 554f949

Please sign in to comment.