-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from danvergara/add-test-scripts
Add test scripts
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.PHONY: test | ||
## test: Runs the tests | ||
test: | ||
go test -v -race ./... | ||
|
||
.PHONY: test-all | ||
## test-all: Runs the integration testing bash script with different database docker image versions | ||
test-all: | ||
@./scripts/test_all.sh | ||
|
||
.PHONY: help | ||
## help: Prints this help message | ||
help: | ||
@echo "Usage:" | ||
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
# | ||
# Integartion testing with dockerized database servers | ||
# | ||
|
||
set -e | ||
|
||
# database credentials | ||
export DBHOST=${DBHOST:-localhost} | ||
export PGUSER="postgres" | ||
export DBPASSWORD="password" | ||
export DATABASE="users" | ||
export PGPORT="15432" | ||
export MYSQL_PORT="13306" | ||
|
||
# Test different versions of postgres available on Docker Hub. | ||
pgversions="9.6 10.16 11.11 12.6 13.2" | ||
|
||
for i in $pgversions | ||
do | ||
PGVERSION="$i" | ||
echo "--------------BEGIN POSTGRES TESTS-------------" | ||
echo "Running test against PostgreSQL v$PGVERSION" | ||
docker rm -f postgres || true | ||
docker run -p $PGPORT:5432 --name postgres -e POSTGRES_PASSWORD=$DBPASSWORD -d postgres:$PGVERSION | ||
sleep 5 | ||
make test | ||
echo "--------------END POSTGRES TESTS-------------" | ||
done | ||
|
||
|
||
# Test different versions of mysql available on Docker Hub. | ||
mysql_versions="5.6 5.7 8.0" | ||
|
||
for i in $mysql_versions | ||
do | ||
MYSQL_VERSION="$i" | ||
echo "--------------BEGIN MYSQL TESTS-------------" | ||
echo "Running test against MySQL v$MYSQL_VERSION" | ||
docker rm -f mysql || true | ||
docker run -p $MYSQL_PORT:3306 --name mysql -e MYSQL_PASSWORD=$DBPASSWORD -d mysql:$MYSQL_VERSION | ||
sleep 5 | ||
make test | ||
echo "--------------END MYSQL TESTS-------------" | ||
done |