integrationdb

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 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, engineName, dsn string) *sql.DB

OpenDB opens a database/sql handle for dsn using the correct driver for engineName.

Types

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