testsupport

package
v0.7.7 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package testsupport provides shared test-only infrastructure helpers (e.g. spinning up throwaway database containers) for use across the module's test files. It is a regular (non-_test.go) package so its helpers can be imported by tests in other packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDockerAvailable

func IsDockerAvailable() bool

IsDockerAvailable reports whether a working Docker daemon is reachable. Portable across platforms (Linux, macOS, Windows).

func StartMongoContainer

func StartMongoContainer(t *testing.T) (uri string, client *mongo.Client, cleanup func())

StartMongoContainer spins up a throwaway MongoDB via testcontainers and returns its connection URI, a connected *mongo.Client, and a cleanup function. Skips the calling test if Docker is not available.

func TestLogger

func TestLogger(t *testing.T) *logger.Log

TestLogger builds a *logger.Log suitable for use in unit tests.

Deliberately does not also provide a tracer helper here: pkg/trace depends on pkg/model, which in turn depends on packages (e.g. pkg/mdoc) that import pkg/cache. Since pkg/cache's own tests import testsupport, pulling pkg/trace/pkg/model into this package would create an import cycle. The shared tracer test helper instead lives in the separate leaf package pkg/testsupport/tracertest, which stays cycle-free.

Types

This section is empty.

Directories

Path Synopsis
Package cachetest provides a generic constructor helper for the near-identical cache.New(ctx, cfg, dbService, tracer, log) tests that exist once per service package (apigw, verifier, registry).
Package cachetest provides a generic constructor helper for the near-identical cache.New(ctx, cfg, dbService, tracer, log) tests that exist once per service package (apigw, verifier, registry).
Package sqltest provides shared Postgres/MariaDB testcontainer helpers, pre-migrated and ready to use, for repository-level SQL store tests, plus NewServiceForTest (service.go) - the shared "build cfg, call a db package's New(), register Close on cleanup" harness every db.Service's SQL contract test uses.
Package sqltest provides shared Postgres/MariaDB testcontainer helpers, pre-migrated and ready to use, for repository-level SQL store tests, plus NewServiceForTest (service.go) - the shared "build cfg, call a db package's New(), register Close on cleanup" harness every db.Service's SQL contract test uses.
Package tracertest provides a shared *trace.Tracer constructor for use in unit tests.
Package tracertest provides a shared *trace.Tracer constructor for use in unit tests.

Jump to

Keyboard shortcuts

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