Add support for running integration tests with dockerized test databases.

This commit is contained in:
go-jet 2021-12-17 16:59:43 +01:00
parent 4d5abc85c6
commit 972fc1d9bf
13 changed files with 210 additions and 67 deletions

30
tests/Readme.md Normal file
View file

@ -0,0 +1,30 @@
# Integration tests
This folder contains integration tests intended to test jet generator, statements and query result mapping with a running database.
## How to run tests?
Before we can run tests, we need to set up and initialize test databases.
To simplify the process there is a Makefile with a list of helper commands.
```shell
# We first need to checkout testdata from separate repository into git submodule,
# then download docker image for each of the databases listed in docker-compose.yaml file, and
# finally run and initialize databases with downloaded test data.
# Note that on the first run this command might take a couple of minutes.
make setup
# When databases are ready, we can generate sql builder and model types needed to compile the tests.
make jet-gen
```
Then we can run the tests the usual way:
```shell
go test -v ./...
```
To removes test containers, volumes, and images:
```shell
make cleanup
# If temp ./.docker folder is still not empty, use 'sudo rm -rf .docker' to remove it.
```