mirror of
https://github.com/xorcare/testing-go-code-with-postgres.git
synced 2025-06-30 23:23:40 +02:00
cdd90f86db7673ee16bfb78ea0febdadf8604654
When a template database name contains invalid characters such as `-`, the request to create a new database stops working. To reduce this behavior, quotation marks have been added.
Example of testing Go code with Postgres
The example suggests a solution to the problem of cleaning the database after running tests and the problem of running tests in parallel. It also shows how to organize integration testing of Go code with Postgres.
What's interesting here?
- Example of docker-compose.yml with multiple databases and automated migrations.
- Example of test database connection management in testingpg package.
- Example of integration tests.
- And example of GitHub Actions and Gitlab CI.
How to use
Run make test-env-up test
and then everything will happen by itself.
Disclaimer
This example is not an example of software architecture!
Description
The example suggests a solution to the problem of cleaning the database after running tests and the problem of running tests in parallel. It also shows how to organize integration testing of Go code with Postgres.
Readme
BSD-3-Clause
339 KiB
Languages
Go
92.6%
Makefile
5%
Shell
2.4%