Create bash script to execute SQL tests

This commit is contained in:
2020-05-12 00:58:52 +02:00
parent 36d60ce6a3
commit b497c61cfc
17 changed files with 57 additions and 278 deletions

View File

@@ -1,33 +1,43 @@
#!/bin/bash
PS3='Please enter your choice: '
options=("RESET DB" "All" "article" "citizen" "comment" "constitution" "follow" "opinion" "user" "vote" "workgroup" "Quit")
select opt in "${options[@]}"
do
case $opt in
"RESET DB")
cat \
../../main/resources/sql/migrations/*.down.sql \
../../main/resources/sql/migrations/*.up.sql > ./allSQL.sql
docker exec -i postgresql_dc-project psql test test -q -b -v "ON_ERROR_STOP=1" < ./allSQL.sql
rm ./allSQL.sql
break;;
"All")
cat ../../main/resources/sql/functions/*/*.sql \
./fixtures/*.sql \
./*.sql > ./allSQL.sql
docker exec -i postgresql_dc-project psql test test -q -b -v "ON_ERROR_STOP=1" < ./allSQL.sql
rm ./allSQL.sql
break;;
"Quit")
break;;
*) echo "Start tests $opt"
cat ../../main/resources/sql/functions/*/*.sql \
./fixtures/*.sql \
./"$opt".sql > ./allSQL.sql
docker exec -i postgresql_dc-project psql test test -q -b -v "ON_ERROR_STOP=1" < ./allSQL.sql
rm ./allSQL.sql
break;;
esac
done
options=("All" "article" "citizen" "comment" "constitution" "follow" "opinion" "user" "vote" "workgroup" "RESET DB" "Quit")
if [ -z "$1" ]; then
PS3='Please enter your choice: '
select ch in "${options[@]}"
do
opt=$ch
break
done
else
opt=${options[${1}-1]}
fi
case $opt in
"RESET DB")
awk 'FNR==1{print "--------------------"}1' \
../../main/resources/sql/migrations/*.down.sql \
../../main/resources/sql/migrations/*.up.sql > ./allSQL.sql
docker exec -i postgresql_dc-project psql test test -q -b -v "ON_ERROR_STOP=1" < ./allSQL.sql
rm ./allSQL.sql
;;
"All")
echo "Start ALL tests"
awk 'FNR==1{print "--------------------"}1' \
../../main/resources/sql/functions/*/*.sql \
./fixtures/*.sql \
./*.sql > ./allSQL.sql
docker exec -i postgresql_dc-project psql test test -q -b -v "ON_ERROR_STOP=1" < ./allSQL.sql
rm ./allSQL.sql
;;
"Quit")
;;
*)
echo "Start tests $opt"
awk 'FNR==1{print "--------------------"}1' \
../../main/resources/sql/functions/*/*.sql \
./fixtures/*.sql \
./"$opt".sql > ./allSQL.sql
docker exec -i postgresql_dc-project psql test test -q -b -v "ON_ERROR_STOP=1" < ./allSQL.sql
rm ./allSQL.sql
;;
esac