Documentation ¶
Index ¶
- Constants
- func CastUnicodeToSymbol(hex int) string
- func ContainerAddress(resource *dockertest.Resource, network *dockertest.Network) string
- func ContainerTcpPort(resource *dockertest.Resource, network *dockertest.Network, port string) string
- func FindPath(containing string) string
- func GenerateString() string
- func GetContainerAddress(resource *dockertest.Resource, network *dockertest.Network) stringdeprecated
- func GetContainerTcpPort(resource *dockertest.Resource, network *dockertest.Network, port string) stringdeprecated
- func GetHostIP(resource *dockertest.Resource, network *dockertest.Network) stringdeprecated
- func GetHostName(resource *dockertest.Resource) stringdeprecated
- func GetRandomName(retry int) string
- func GetStatusSymbol(exitCode int) string
- func GetSymbol(name string) string
- func HostIP(resource *dockertest.Resource, network *dockertest.Network) string
- func HostName(resource *dockertest.Resource) string
- func IsDockerRunning() bool
- func IsRunningInContainer() bool
- func MemoryMB() int64
- func Retry(d time.Duration, op func() error) error
- func UseBridgeNetwork(network *dockertest.Network) bool
- func WaitForContainer(pool *dockertest.Pool, resource *dockertest.Resource) (int, error)
- type BaseFixture
- type ConnectionSettings
- type Docker
- func (f *Docker) GetName() stringdeprecated
- func (f *Docker) GetNamePrefix() stringdeprecated
- func (f *Docker) GetNetwork() *dockertest.Networkdeprecated
- func (f *Docker) GetNetworkName() stringdeprecated
- func (f *Docker) GetPool() *dockertest.Pooldeprecated
- func (f *Docker) Name() string
- func (f *Docker) NamePrefix() string
- func (f *Docker) Network() *dockertest.Network
- func (f *Docker) NetworkName() string
- func (f *Docker) Pool() *dockertest.Pool
- func (f *Docker) Purge(r *dockertest.Resource)
- func (f *Docker) SetUp(ctx context.Context) error
- func (f *Docker) TearDown(context.Context) error
- type DockerOpt
- type Fixture
- type Fixtures
- func (f *Fixtures) Add(ctx context.Context, fixtures ...Fixture) error
- func (f *Fixtures) AddByName(ctx context.Context, name string, fixture Fixture) error
- func (f *Fixtures) Docker() *Docker
- func (f *Fixtures) Get(name string) Fixture
- func (f *Fixtures) Postgres() *Postgres
- func (f *Fixtures) RecoverTearDown(ctx context.Context)
- func (f *Fixtures) SetUp(ctx context.Context) error
- func (f *Fixtures) TearDown(ctx context.Context) error
- type FixturesOpt
- type Postgres
- func (f *Postgres) ConnConfig() (*pgxpool.Config, error)
- func (f *Postgres) Connect(ctx context.Context, opts ...PostgresConnOpt) (*pgxpool.Pool, error)
- func (f *Postgres) CopyDatabase(ctx context.Context, source string, target string) error
- func (f *Postgres) CreateDatabase(ctx context.Context, name string) error
- func (f *Postgres) DropDatabase(ctx context.Context, name string) error
- func (f *Postgres) Dump(ctx context.Context, dir string, filename string) error
- func (f *Postgres) GetConnConfig() (*pgxpool.Config, error)deprecated
- func (f *Postgres) GetConnection(ctx context.Context, database string) (*pgx.Conn, error)deprecated
- func (f *Postgres) GetHostName() stringdeprecated
- func (f *Postgres) GetSettings() *ConnectionSettingsdeprecated
- func (f *Postgres) GetTableColumns(ctx context.Context, database, schema, table string) ([]string, error)deprecated
- func (f *Postgres) GetTables(ctx context.Context, database string) ([]string, error)deprecated
- func (f *Postgres) HostName() string
- func (f *Postgres) LoadSql(ctx context.Context, path string) error
- func (f *Postgres) LoadSqlPattern(ctx context.Context, pattern string) error
- func (f *Postgres) MustConnect(ctx context.Context, opts ...PostgresConnOpt) *pgxpool.Pool
- func (f *Postgres) Ping(ctx context.Context) error
- func (f *Postgres) PingPsql(ctx context.Context) error
- func (f *Postgres) Psql(ctx context.Context, cmd []string, mounts []string, quiet bool) (int, error)
- func (f *Postgres) Restore(ctx context.Context, dir string, filename string) error
- func (f *Postgres) SetUp(ctx context.Context) error
- func (f *Postgres) Settings() *ConnectionSettings
- func (f *Postgres) TableColumns(ctx context.Context, database, schema, table string) ([]string, error)
- func (f *Postgres) TableExists(ctx context.Context, database, schema, table string) (bool, error)
- func (f *Postgres) Tables(ctx context.Context, database string) ([]string, error)
- func (f *Postgres) TearDown(ctx context.Context) error
- func (f *Postgres) ValidateModel(ctx context.Context, databaseName string, i interface{}) error
- func (f *Postgres) ValidateModels(ctx context.Context, databaseName string, i ...interface{}) error
- func (f *Postgres) WaitForReady(ctx context.Context, d time.Duration) error
- type PostgresConnConfig
- type PostgresConnOpt
- type PostgresOpt
- func PostgresDocker(d *Docker) PostgresOpt
- func PostgresExpireAfter(expireAfter uint) PostgresOpt
- func PostgresLogger(logger *zap.Logger) PostgresOpt
- func PostgresMounts(mounts []string) PostgresOpt
- func PostgresRepo(repo string) PostgresOpt
- func PostgresSettings(settings *ConnectionSettings) PostgresOpt
- func PostgresSkipTearDown() PostgresOpt
- func PostgresTimeoutAfter(timeoutAfter uint) PostgresOpt
- func PostgresVersion(version string) PostgresOpt
Constants ¶
const ( DEFAULT_POSTGRES_REPO = "postgres" DEFAULT_POSTGRES_VERSION = "13-alpine" )
Variables ¶
This section is empty.
Functions ¶
func CastUnicodeToSymbol ¶
func ContainerAddress ¶
func ContainerAddress(resource *dockertest.Resource, network *dockertest.Network) string
GetContainerAddress returns the address at which requests from the tests can be made into the container. When running inside a host container and connected to a bridge network, this returns the address of the container as known by the container network. When running inside a host container and not connected to a bridge network, this returns the network gateway. When not running inside a host container it returns localhost.
func ContainerTcpPort ¶
func ContainerTcpPort(resource *dockertest.Resource, network *dockertest.Network, port string) string
GetContainerTcpPort returns the port which can be used to connect into the container from the test. When connected to a bridge network, the container exposed port can be used. Otherwise, we'll need to use the mapped port.
func GenerateString ¶
func GenerateString() string
func GetContainerAddress
deprecated
func GetContainerAddress(resource *dockertest.Resource, network *dockertest.Network) string
Deprecated: use ContainerAddress()
func GetContainerTcpPort
deprecated
func GetHostName
deprecated
func GetHostName(resource *dockertest.Resource) string
Deprecated: use HostName()
func GetRandomName ¶ added in v2.3.3
func GetStatusSymbol ¶
func IsDockerRunning ¶
func IsDockerRunning() bool
func IsRunningInContainer ¶
func IsRunningInContainer() bool
IsRunningInContainer checks if the current executable is running inside a container. This implementation is currently docker-specific and won't work on other container engines, such as podman. A more portable solution is probably more ideal.
func UseBridgeNetwork ¶
func UseBridgeNetwork(network *dockertest.Network) bool
func WaitForContainer ¶
Types ¶
type BaseFixture ¶
type BaseFixture struct{}
func (*BaseFixture) Type ¶
func (f *BaseFixture) Type() string
type ConnectionSettings ¶
type ConnectionSettings struct { Driver string Host string Port string User string Password string Database string DisableSSL bool MaxOpenConns int }
func (*ConnectionSettings) Connect ¶
func (cs *ConnectionSettings) Connect(ctx context.Context) (*pgx.Conn, error)
func (*ConnectionSettings) Copy ¶
func (cs *ConnectionSettings) Copy() *ConnectionSettings
func (*ConnectionSettings) String ¶
func (cs *ConnectionSettings) String() string
type Docker ¶
type Docker struct { BaseFixture // contains filtered or unexported fields }
func (*Docker) GetNamePrefix
deprecated
func (*Docker) GetNetwork
deprecated
func (f *Docker) GetNetwork() *dockertest.Network
Deprecated: use Network()
func (*Docker) GetNetworkName
deprecated
func (*Docker) NamePrefix ¶
func (*Docker) NetworkName ¶
type DockerOpt ¶
type DockerOpt func(*Docker)
func DockerLogger ¶
func DockerName ¶
func DockerNamePrefix ¶
func DockerNetworkName ¶
type Fixtures ¶
type Fixtures struct {
// contains filtered or unexported fields
}
func NewFixtures ¶
func NewFixtures(opts ...FixturesOpt) *Fixtures
func (*Fixtures) RecoverTearDown ¶
RecoverTearDown returns a deferrable function that will teardown in the event of a panic.
type FixturesOpt ¶
type FixturesOpt func(*Fixtures)
func FixturesLogger ¶
func FixturesLogger(logger *zap.Logger) FixturesOpt
type Postgres ¶
type Postgres struct { BaseFixture // contains filtered or unexported fields }
func NewPostgres ¶
func NewPostgres(d *Docker, opts ...PostgresOpt) *Postgres
func (*Postgres) CopyDatabase ¶
CopyDatabase creates a copy of an existing postgres database using `createdb --template={source} {target}` source will default to the primary database
func (*Postgres) CreateDatabase ¶
func (*Postgres) DropDatabase ¶
func (*Postgres) GetConnConfig
deprecated
func (*Postgres) GetHostName
deprecated
func (*Postgres) GetSettings
deprecated
func (f *Postgres) GetSettings() *ConnectionSettings
Deprecated: use Settings()
func (*Postgres) LoadSql ¶
LoadSql runs a file or directory of *.sql files against the default postgres database.
func (*Postgres) LoadSqlPattern ¶
LoadSqlPattern finds files matching a custom pattern and runs them against the default database.
func (*Postgres) MustConnect ¶
func (*Postgres) Settings ¶
func (f *Postgres) Settings() *ConnectionSettings
func (*Postgres) TableColumns ¶
func (*Postgres) TableExists ¶
func (*Postgres) ValidateModel ¶
func (*Postgres) ValidateModels ¶
type PostgresConnConfig ¶
type PostgresConnConfig struct {
// contains filtered or unexported fields
}
type PostgresConnOpt ¶
type PostgresConnOpt func(*PostgresConnConfig)
func PostgresConnCreateCopy ¶
func PostgresConnCreateCopy() PostgresConnOpt
func PostgresConnDatabase ¶
func PostgresConnDatabase(database string) PostgresConnOpt
func PostgresConnRole ¶
func PostgresConnRole(role string) PostgresConnOpt
type PostgresOpt ¶
type PostgresOpt func(*Postgres)
func PostgresDocker ¶
func PostgresDocker(d *Docker) PostgresOpt
func PostgresExpireAfter ¶
func PostgresExpireAfter(expireAfter uint) PostgresOpt
Tell docker to kill the container after an unreasonable amount of test time to prevent orphans. Defaults to 600 seconds.
func PostgresLogger ¶
func PostgresLogger(logger *zap.Logger) PostgresOpt
func PostgresMounts ¶
func PostgresMounts(mounts []string) PostgresOpt
func PostgresRepo ¶
func PostgresRepo(repo string) PostgresOpt
func PostgresSettings ¶
func PostgresSettings(settings *ConnectionSettings) PostgresOpt
func PostgresSkipTearDown ¶
func PostgresSkipTearDown() PostgresOpt
func PostgresTimeoutAfter ¶
func PostgresTimeoutAfter(timeoutAfter uint) PostgresOpt
Wait this long for operations to execute. Defaults to 30 seconds.
func PostgresVersion ¶
func PostgresVersion(version string) PostgresOpt