Documentation
¶
Overview ¶
Package natstest starts an embedded, in-process nats-server with JetStream enabled for use in tests. It is a real server (no client mocks): packtrail's correctness is about NATS semantics, so every test runs against the genuine article. Restart supports fault-injection tests that bounce the server while keeping its storage.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶ added in v1.0.0
type Cluster struct {
NC *nats.Conn
JS jetstream.JetStream
// contains filtered or unexported fields
}
Cluster is a running embedded JetStream cluster.
func StartCluster ¶ added in v1.0.0
StartCluster launches an n-node JetStream cluster (for replication tests) and waits until it has a meta leader.
type Server ¶
type Server struct {
NC *nats.Conn
JS jetstream.JetStream
// contains filtered or unexported fields
}
Server is a running embedded nats-server with a connected client.
func Start ¶
Start launches an embedded JetStream-enabled nats-server on a random port, returns a connected client and a JetStream context, and registers cleanup with the test.
func (*Server) Connect ¶ added in v0.2.0
Connect opens a second, independent connection to the same server, closed when the test ends. Use it where the point under test is that two separate processes share only a NATS cluster. The connection reconnects forever, so it survives Restart.
func (*Server) HasSubscription ¶ added in v1.0.0
HasSubscription reports whether some client is subscribed to subject (in the global account).