forked from gobuffalo/pop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·79 lines (67 loc) · 1.55 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
########################################################
# test.sh is a wrapper to execute integration tests for
# pop.
########################################################
set -e
clear
VERBOSE=""
DEBUG='NO'
for i in "$@"
do
case $i in
-v)
VERBOSE="-v"
shift
;;
-d)
DEBUG='YES'
shift
;;
*)
# unknown option
;;
esac
done
function cleanup {
echo "Cleanup resources..."
docker-compose down
rm tsoda
find ./sql_scripts/sqlite -name *.sqlite* -delete
}
# defer cleanup, so it will be executed even after premature exit
trap cleanup EXIT
docker-compose up -d
sleep 4 # Ensure mysql is online
go build -v -tags sqlite -o tsoda ./soda
export GO111MODULE=on
function test {
echo "!!! Testing $1"
export SODA_DIALECT=$1
echo ./tsoda -v
echo "Setup..."
./tsoda drop -e $SODA_DIALECT -c ./database.yml
./tsoda create -e $SODA_DIALECT -c ./database.yml
./tsoda migrate -e $SODA_DIALECT -c ./database.yml
echo "Test..."
go test -race -tags sqlite $VERBOSE ./... -count=1
}
function debug_test {
echo "!!! Debug Testing $1"
export SODA_DIALECT=$1
echo ./tsoda -v
echo "Setup..."
./tsoda drop -e $SODA_DIALECT -c ./database.yml
./tsoda create -e $SODA_DIALECT -c ./database.yml
./tsoda migrate -e $SODA_DIALECT -c ./database.yml
echo "Test and debug..."
dlv test github.com/gobuffalo/pop
}
dialects=("postgres" "cockroach" "mysql" "sqlite")
for dialect in "${dialects[@]}" ; do
if [ $DEBUG = 'NO' ]; then
test ${dialect}
else
debug_test ${dialect}
fi
done