packtrailtest

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package packtrailtest runs an embedded, in-process nats-server with JetStream enabled, for testing applications built on packtrail. It is a real server, so engines, workers and clients behave exactly as in production; Restart bounces it while keeping its storage, to test how an application rides out a NATS outage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is a running embedded nats-server, shut down when the test ends.

func Start

func Start(t testing.TB) *Server

Start launches a JetStream-enabled server on a random loopback port, with its storage in a temporary directory of the test.

func (*Server) Connect

func (s *Server) Connect(t testing.TB) *nats.Conn

Connect opens a new connection to the server, closed when the test ends. Give each engine, worker and client its own connection to model separate processes. The connection reconnects forever, so it survives Restart.

func (*Server) Restart

func (s *Server) Restart(t testing.TB)

Restart shuts the server down and boots it again on the same port with the same storage: JetStream state survives and connections reconnect.

func (*Server) URL

func (s *Server) URL() string

URL returns the client URL of the server. It does not change on Restart.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL