Documentation
¶
Overview ¶
Package stdpgtest provides testing against a postgresql database.
Index ¶
- func Execute(ctx context.Context, stdin io.Reader, dir, program string, args ...string) (string, error)
- func NewPgxTestDB(tb testing.TB, migrator pgtestdb.Migrator, setupConnStr string, ...) *pgtestdb.Config
- func SetupPgxPool(ctx context.Context, tb testing.TB, snapshot []byte, connString string) *pgxpool.Pool
- type AtlasDirMigrator
- type ExecuteFunc
- type SnapshotMigrator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Execute ¶ added in v0.0.26
func Execute(ctx context.Context, stdin io.Reader, dir, program string, args ...string) (string, error)
Execute shells out to a `program`, passing it STDIN (if given) and any specified arguments.
Examples:
Execute(ctx, nil, "echo", "hello", "world" Execute(ctx, nil, "bash", "-c", "echo 'hello world'"
Types ¶
type AtlasDirMigrator ¶ added in v0.0.24
type AtlasDirMigrator struct { MigrationsDirPath string AtlasEnv string AtlasConfig string Dir string // contains filtered or unexported fields }
AtlasDirMigrator is a pgtestdb.Migrator that uses the `atlas` CLI tool to perform migrations.
atlas migrate apply --url $DB --dir file://$migrationsDirPath
AtlasDirMigrator requires that it runs in an environment where the `atlas` CLI is in the $PATH. It shells out to that program to perform its migrations, as recommended by the Atlas maintainers.
AtlasDirMigrator does not perform any Verify() or Prepare() logic.
func NewAtlasDirMigrator ¶ added in v0.0.24
func NewAtlasDirMigrator( migrationsDirPath string, atlasEnv string, atlasConfig string, dir string, execute ExecuteFunc, ) *AtlasDirMigrator
NewAtlasDirMigrator returns a AtlasDirMigrator, which is a pgtestdb.Migrator that uses the `atlas` CLI tool to perform migrations.
atlas migrate apply --url $DB --dir file://$migrationsDirPath
func (*AtlasDirMigrator) Hash ¶ added in v0.0.24
func (m *AtlasDirMigrator) Hash() (string, error)
type ExecuteFunc ¶ added in v0.0.26
type ExecuteFunc func(ctx context.Context, stdin io.Reader, dir, program string, args ...string) (string, error)
ExecuteFunc defines the signature for executing a command.
type SnapshotMigrator ¶ added in v0.0.24
type SnapshotMigrator[T interface { ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) }] []byte
SnapshotMigrator loads a migration from a postgres dump file.
func (SnapshotMigrator[T]) Hash ¶ added in v0.0.24
func (m SnapshotMigrator[T]) Hash() (string, error)
Hash implements the migrater interface.