Documentation
¶
Index ¶
- Constants
- func MustFreePort(t *testing.T) int
- func OpenDB(t *testing.T, engineName, dsn string) *sql.DB
- type Database
- func (db *Database) HostConnection(host string) engine.ConnectionConfig
- func (db *Database) HostDSN(host string) string
- func (db *Database) HostSourceConfig(host string) engine.SourceConfig
- func (db *Database) LocalConnection() engine.ConnectionConfig
- func (db *Database) LocalDSN() string
- func (db *Database) NetworkSourceConfig() engine.SourceConfig
- type Suite
Constants ¶
const ( EnginePostgres = "postgres" EngineMySQL = "mysql" )
Variables ¶
This section is empty.
Functions ¶
func MustFreePort ¶
MustFreePort returns an available TCP port on the host.
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 ¶
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) 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 (*Suite) HostAccessAddress ¶
HostAccessAddress returns a non-loopback IP address that helper containers can use to reach services published on the host.
func (*Suite) StartCopy ¶
StartCopy starts a copy or staging container with /dump mounted from dumpDir.
func (*Suite) StartSource ¶
StartSource starts a source database container with a host-visible port and a network alias so tests can use either path.