github.com/nshntarora/pop@v0.1.2/test.sh (about) 1 #!/bin/bash 2 3 set -e 4 5 # NOTE: See also docker-compose.yml and database.yml to configure database 6 # properties. 7 export MYSQL_PORT=3307 8 export COCKROACH_PORT=26258 9 10 COMPOSE=docker-compose 11 which docker-compose || COMPOSE="docker compose" 12 13 args=$@ 14 15 function cleanup { 16 echo "Cleanup resources..." 17 $COMPOSE down 18 docker volume prune -f 19 rm tsoda 20 find ./tmp -name *.sqlite* -delete || true 21 } 22 # defer cleanup, so it will be executed even after premature exit 23 trap cleanup EXIT 24 25 function test { 26 export SODA_DIALECT=$1 27 28 echo "" 29 echo "######################################################################" 30 echo "### Running unit tests for $SODA_DIALECT" 31 ./tsoda drop -e $SODA_DIALECT -c ./database.yml -p ./testdata/migrations 32 ./tsoda create -e $SODA_DIALECT -c ./database.yml -p ./testdata/migrations 33 ./tsoda migrate -e $SODA_DIALECT -c ./database.yml -p ./testdata/migrations 34 go test -cover -race -tags sqlite -count=1 $args ./... 35 } 36 37 function debug_test { 38 export SODA_DIALECT=$1 39 40 echo "" 41 echo "######################################################################" 42 echo "### Running unit tests for $SODA_DIALECT" 43 ./tsoda drop -e $SODA_DIALECT -c ./database.yml -p ./testdata/migrations 44 ./tsoda create -e $SODA_DIALECT -c ./database.yml -p ./testdata/migrations 45 ./tsoda migrate -e $SODA_DIALECT -c ./database.yml -p ./testdata/migrations 46 dlv test github.com/gobuffalo/pop 47 } 48 49 dialects="postgres cockroach mysql sqlite" 50 51 $COMPOSE up --wait 52 53 go build -v -tags sqlite -o tsoda ./soda 54 55 for dialect in $dialects; do 56 if [ "$DEBUG" = "YES" ]; then 57 debug_test ${dialect} 58 else 59 test ${dialect} 60 fi 61 done