integrationdb

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnginePostgres = "postgres"
	EngineMySQL    = "mysql"
)

Variables

This section is empty.

Functions

func MustFreePort

func MustFreePort(t *testing.T) int

MustFreePort returns an available TCP port on the host.

func OpenDB

func OpenDB(t *testing.T, conn DBConn) *sql.DB

OpenDB opens a database/sql handle for the given connection using the correct driver for its engine.

Types

type DBConn added in v0.3.3

type DBConn struct {
	EngineName string
	DSN        string
}

DBConn bundles an engine name with a DSN, eliminating loose primitive pairs that appear throughout the integration helpers.

type Database

type Database struct {
	Suite       *Suite
	Name        string
	ContainerID string
	Port        int
	Bootstrap   engine.CopyBootstrap
}

Database describes a running source or copy container managed by Suite.

func (*Database) HostConnection

func (db *Database) HostConnection(host string) engine.ConnectionConfig

HostConnection returns a connection config pointing at host.

func (*Database) HostDSN

func (db *Database) HostDSN(host string) string

HostDSN returns the DSN helper containers can use to query the running DB.

func (*Database) HostSourceConfig

func (db *Database) HostSourceConfig(host string) engine.SourceConfig

HostSourceConfig returns a dump source config that reaches the published host port through host.

func (*Database) LocalConnection

func (db *Database) LocalConnection() engine.ConnectionConfig

LocalConnection returns the host-local connection config for the running DB.

func (*Database) LocalDSN

func (db *Database) LocalDSN() string

LocalDSN returns the DSN the host can use to query the running DB.

func (*Database) NetworkSourceConfig

func (db *Database) NetworkSourceConfig() engine.SourceConfig

NetworkSourceConfig returns a dump source config that resolves through the suite's private Docker network.

type Suite

type Suite struct {
	Docker      *client.Client
	Engine      engine.Engine
	EngineName  string
	NetworkName string
	// contains filtered or unexported fields
}

Suite owns one Docker client and one isolated network for a single integration test case.

func NewSuite

func NewSuite(t *testing.T, engineName string) *Suite

NewSuite creates an isolated Docker network for one engine-specific test.

func (*Suite) HostAccessAddress

func (s *Suite) HostAccessAddress() string

HostAccessAddress returns a non-loopback IP address that helper containers can use to reach services published on the host.

func (*Suite) StartCopy

func (s *Suite) StartCopy(dumpDir string) *Database

StartCopy starts a copy or staging container with /dump mounted from dumpDir.

func (*Suite) StartSource

func (s *Suite) StartSource() *Database

StartSource starts a source database container with a host-visible port and a network alias so tests can use either path.

Jump to

Keyboard shortcuts

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