Help us shape the future of Go! Take the 2026 Go Developer Survey

testhelpers

package
v0.0.0-...-9850b09 Latest Latest
Warning

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

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

Documentation

Overview

Package testhelpers provides shared fixtures for integration tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryStorage

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

MemoryStorage substitutes only object bytes. Integration tests still use the real media use case, source rows, ownership checks and reference transactions.

func NewMemoryStorage

func NewMemoryStorage() *MemoryStorage

func (*MemoryStorage) Copy

func (s *MemoryStorage) Copy(_ context.Context, src, dst string) error

func (*MemoryStorage) Get

func (*MemoryStorage) GetRange

func (s *MemoryStorage) GetRange(_ context.Context, key string, offset, length int64) (io.ReadCloser, error)

func (*MemoryStorage) Put

func (s *MemoryStorage) Put(_ context.Context, key string, r io.Reader, _ int64, _ string) error

func (*MemoryStorage) Remove

func (s *MemoryStorage) Remove(_ context.Context, key string) error

func (*MemoryStorage) Stat

func (s *MemoryStorage) Stat(_ context.Context, key string) (bool, error)

type TestDB

type TestDB struct {
	Pool    *pgxpool.Pool
	Queries *postgres.Queries
}

TestDB is a disposable PostgreSQL instance with the real schema applied — integration tests exercise the actual sqlc queries against it instead of mocks.

func SetupTestDB

func SetupTestDB(t *testing.T) *TestDB

SetupTestDB gives the test its own PostgreSQL database with the real schema (cloned from a template inside one shared container, started by the first test of the binary) and returns live Queries. The database is dropped via t.Cleanup. When Docker is not available the test is skipped, so the suite stays runnable on machines without it.

Jump to

Keyboard shortcuts

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