Utilities for testing Golang code that runs SQL.
# Postgres version is "12"
pg, _ := sqltestutil.StartPostgresContainer(context.Background(), "12")
defer pg.Shutdown(ctx)
db, err := sql.Open("postgres", pg.ConnectionString())
// ... execute SQL
PostgresContainer is a Docker container running Postgres that can be used to cheaply start a throwaway Postgres instance for testing.
RunMigration reads all of the files matching *.up.sql in a directory and executes them in lexicographical order against the provided DB.
LoadScenario reads a YAML "scenario" file and uses it to populate the given DB.
Suite is a testify suite that provides a database connection for running tests against a SQL database.