Documentation
¶
Overview ¶
Package sqltest runs a component test against a real postgres. See waffle/docs/conventions/component-harness.md.
Index ¶
- type DockerOption
- type MigrateFunc
- type Option
- type Postgres
- func (p *Postgres) Db() sql.Db
- func (p *Postgres) Down(ctx context.Context) error
- func (p *Postgres) FailWith(err error)
- func (p *Postgres) Handle() *dbSql.DB
- func (p *Postgres) Migrate(ctx context.Context) error
- func (p *Postgres) Name() string
- func (p *Postgres) Provision(ctx context.Context) error
- func (p *Postgres) Reset(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DockerOption ¶
type DockerOption func(*container)
func Container ¶
func Container(name string) DockerOption
func Port ¶
func Port(port int) DockerOption
type MigrateFunc ¶
Taken as a function rather than driven from here, to keep goose out of the sql module's dependency graph, which every service carries.
type Option ¶
type Option func(*Postgres)
func Docker ¶
func Docker(image string, opts ...DockerOption) Option
Last resort, after Dsn and Env. Trust authentication, so no password exists to keep anywhere; a binary rather than testcontainers, to stay out of go.mod.
func Env ¶
First non-empty wins. There is no built-in default, because one carrying a password would put a credential in this repository.
func Ephemeral ¶
func Ephemeral() Option
The process id in the name is what lets `go test ./...` run two packages at once. So the name in a DSN is not the name used.
func Migrations ¶
func Migrations(migrate MigrateFunc) Option
type Postgres ¶
type Postgres struct {
// contains filtered or unexported fields
}
func (*Postgres) Down ¶
The container, if one was started, is left running: starting it is the only part that costs anything, and the next run reuses it.