testutil

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CockroachDBBackend added in v0.2.0

func CockroachDBBackend(t *testing.T) (connStr string, backend string)

CockroachDBBackend starts a shared single-node CockroachDB container (once per test binary) and returns the admin connection string and host:port backend address.

func MongoDBBackend added in v0.6.3

func MongoDBBackend(t *testing.T) (connStr string, backend string)

MongoDBBackend starts a shared MongoDB 8 container with authentication enabled (once per test binary) and returns the admin connection string and host:port backend address.

func PostgresBackend

func PostgresBackend(t *testing.T) (connStr string, backend string)

PostgresBackend starts a shared PostgreSQL 16-alpine container (once per test binary) and returns the admin connection string and host:port backend address.

func RedisClient

func RedisClient(t *testing.T) *redis.Client

RedisClient starts a shared Redis 7-alpine container (once per test binary) and returns a connected client. The client is closed when the test finishes.

func RedisClientRaw

func RedisClientRaw(t *testing.T) *redis.Client

RedisClientRaw returns the shared Redis client without flushing. Use this when you need to manipulate Redis state mid-test without losing data set by prior operations in the same test.

func RedisClusterClient added in v0.6.0

func RedisClusterClient(t *testing.T) *redis.Client

RedisClusterClient starts a single-node Redis in cluster mode (once per test binary) and returns a connected client. The server enforces cluster hash slot semantics, so multi-key Lua scripts operating across different slots will fail with CROSSSLOT errors — exactly like a production Redis Cluster would.

Types

type MongoRSInfo added in v0.6.3

type MongoRSInfo struct {
	ConnStr string   // mongodb://admin:adminpass@host1:port1,host2:port2,host3:port3/?replicaSet=rs0&authSource=admin
	Primary string   // host:port of the primary (mapped port on host)
	Members []string // all member host:port addresses (mapped ports on host)
}

MongoRSInfo contains connection info for a multi-node MongoDB replica set.

func MongoDBReplicaSet added in v0.6.3

func MongoDBReplicaSet(t *testing.T) *MongoRSInfo

MongoDBReplicaSet starts a shared 3-node MongoDB replica set (once per test binary) and returns connection info. The RS uses auth with admin/adminpass. Each call cleans up provisioned users and non-system databases for isolation.

Jump to

Keyboard shortcuts

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