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