testhelper

package
v0.0.0-...-748ecea Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CockroachDBImage           = `cockroachdb/cockroach`
	CockroachDBVersion         = `v23.1.12`
	CockroachDBDefaultEndpoint = ``
	CockroachDBDefaultHost     = `localhost`
)

Default values for making cockroachDB test container.

View Source
const (
	MinioImage           = `docker.io/bitnami/minio`
	MinioVersion         = `2023`
	MinioDefaultEndpoint = ``
	MinioDefaultHost     = `localhost`
)

Default values for making nats test container.

View Source
const (
	NATSImage           = `nats`
	NATSVersion         = `2.10.5`
	NATSDefaultEndpoint = ``
	NATSDefaultHost     = `localhost`
)

Default values for making nats test container.

View Source
const Host = `127.0.0.1`

Host is std test host.

View Source
const MaxTimeout = time.Second * 120

MaxTimeout for tests.

Variables

This section is empty.

Functions

func Addr

func Addr(t *testing.T, assert *require.Assertions) netip.AddrPort

Addr returns free test host:port.

func CockroachDB

func CockroachDB(
	ctx context.Context,
	t *testing.T,
	assert *require.Assertions,
	caCrtPath, caKeyPath string,
	nodeCrtPath, nodeKeyPath string,
	clientCrtPath, clientKeyPath string,
) *connectors.CockroachDB

CockroachDB build and run test container with database.

Notice:

  • Starts CockroachDB container;
  • Make connections by root certs;
  • Make new database/user and grant access.

func Context

func Context(t *testing.T) context.Context

Context build new context for tests and set cleanup cancel function.

func Minio

func Minio(
	ctx context.Context,
	t *testing.T,
	assert *require.Assertions,
	accessKey, secretKey, sessionToken string,
	secure bool,
	region string,
) string

Minio build and run test container with file storage.

Notice:

  • Starts Minio container;
  • Make connections by credentials;

func Mod

func Mod[T any](v T, f func(*T)) T

Mod applies given modification to any value.

func NATS

func NATS(
	ctx context.Context,
	t *testing.T,
	assert *require.Assertions,
	cfgFilePath string,
	username, password string,
) string

NATS build and run test container with message broker.

Notice:

  • Starts NATS container;
  • Make connections by credentials;

func Namespace

func Namespace(t *testing.T) string

func UnusedTCPPort

func UnusedTCPPort(t *testing.T, assert *require.Assertions, host string) uint16

UnusedTCPPort returns random unique unused TCP port at host.

func WaitTCPPort

func WaitTCPPort(ctx context.Context, addr string) error

WaitTCPPort tries to connect to addr until success or ctx.Done.

Types

This section is empty.

Jump to

Keyboard shortcuts

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