testutil

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 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 MongoDBBackendSecondary added in v0.6.9

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

MongoDBBackendSecondary starts a second, fully independent MongoDB container (once per test binary) and returns its connection info. It exists so tests can configure two distinct clusters and verify each listener routes to its own backend rather than both pointing at the same one.

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.

type MongoShardedInfo added in v0.7.0

type MongoShardedInfo struct {
	ConnStr string   // mongodb://admin:adminpass@mongos1,mongos2/?authSource=admin
	Mongos  []string // mapped host:port for each mongos router
}

MongoShardedInfo contains connection info for a sharded MongoDB cluster (config-server replica set + shard replica sets fronted by mongos routers).

func MongoDBShardedCluster added in v0.7.0

func MongoDBShardedCluster(t *testing.T) *MongoShardedInfo

MongoDBShardedCluster starts a shared sharded MongoDB cluster (once per test binary): a 3-node config-server replica set, two 3-node shard replica sets, and two mongos routers. Auth uses admin/adminpass with a shared keyFile for internal cluster auth. Each call cleans up provisioned users and non-system databases (via a mongos) for isolation.

Jump to

Keyboard shortcuts

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