testfixture

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 31 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testfixture provides local targets without using user services.

Index

Constants

View Source
const HealthProto = `` /* 202-byte string literal not displayed */
View Source
const HealthTypesProto = `` /* 213-byte string literal not displayed */
View Source
const LocalHBA = `` /* 255-byte string literal not displayed */

Variables

This section is empty.

Functions

func CleanupContext

func CleanupContext() (context.Context, context.CancelFunc)

func EnsureLocalPKI

func EnsureLocalPKI(dir string) error

Types

type Certificates

type Certificates struct {
	CA, Client, Key string
	Server          tls.Certificate
	Pool            *x509.CertPool
}

func IssueLocalClient

func IssueLocalClient(dir, role string) (Certificates, error)

func NewCertificates

func NewCertificates() (Certificates, error)

func (Certificates) ServerTLS

func (c Certificates) ServerTLS() *tls.Config

type Database

type Database struct {
	ID, Nonce                                     string
	Namespace                                     dbscope.Namespace
	AppURL, ReaderURL, TargetURL                  string
	AppRole, ReaderRole, TargetRole, TargetSchema string
	// contains filtered or unexported fields
}

Database owns schemas and restricted roles in the existing qag database. AdminURL is kept private: it must never be passed to the app or SQL runner.

func ForTest

func ForTest(t TestContext, ctx context.Context) *Database

func NewDatabase

func NewDatabase(ctx context.Context, adminURL string) (*Database, error)

func (*Database) AdoptRestored

func (f *Database) AdoptRestored(ctx context.Context) error

func (*Database) Cleanup

func (f *Database) Cleanup(ctx context.Context, id, nonce string) error

func (*Database) Close

func (f *Database) Close(ctx context.Context) error

func (*Database) EnableMTLS

func (f *Database) EnableMTLS(ctx context.Context, dir string) (string, Certificates, error)

EnableMTLS grants a certificate-only role access to this fixture's target.

func (*Database) RenameSource

func (f *Database) RenameSource(ctx context.Context) error

RenameSource frees only this fixture's schema names for a native pg_restore. The old objects and their OIDs remain in the same validated manifest.

type Targets

type Targets struct {
	HTTP    *httptest.Server
	GRPC    string
	Calls   atomic.Int32
	Flaky   atomic.Int32
	Sources atomic.Int32
	// contains filtered or unexported fields
}

func Start

func Start(cert *Certificates, withReflection bool) (*Targets, error)

func (*Targets) Close

func (t *Targets) Close()

type TestContext

type TestContext interface {
	Helper()
	Cleanup(func())
	Fatalf(string, ...any)
}

Jump to

Keyboard shortcuts

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