internal/testing/integration/README.md
This directory contains integration tests for the pressly/goose/v3 Go module. An integration test is a test that runs against a real database (docker container) and exercises the same driver used by the CLI.
There are separate go.mod and go.sum files in this directory to allow for the use of different
dependencies. We leverage multi-module workspaces to glue
things together.
Namely, we want to avoid dependencies on docker, sql drivers, and other dependencies that are not necessary for the core functionality of the goose library.
There are separate migration files for each database that we support, see the migrations directory. Databases typically have different SQL syntax and features, so the migration files are different.
A good set of migrations should be representative of the types of migrations users will write typically write. This should include:
StatementBegin and StatementEnd
annotations-- +goose NO TRANSACTIONThere is a common test function that applies migrations up, down and then up again.
The gold standard is the PostgreSQL migration files. We try to make other migration files as close to the PostgreSQL files as possible, but this is not always possible or desirable.
Lastly, some tests will assert for database state after migrations are applied.
To add a new .sql file, you can use the following command:
goose -s -dir testdata/migrations/<database_name> create <filename> sql
postgres)b) as neededNote, the integration tests are not exhaustive.
They are meantto ensure that the goose library works with the various databases that we support and the chosen drivers. We do not test every possible combination of operations, nor do we test every possible edge case. We rely on the unit tests in the goose package to cover library-specific logic.