2021-05-28 18:13:28 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-10-11 12:29:38 +03:00
|
|
|
echo "Compiling."
|
2022-09-08 22:13:13 +03:00
|
|
|
CGO_ENABLED=0 go build
|
2021-05-28 18:13:28 +03:00
|
|
|
|
|
|
|
if ! command -v newman &> /dev/null
|
|
|
|
then
|
|
|
|
echo "Newman could not be found. Run 'npm install -g newman' first."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
|
|
|
echo "Creating database and schema ..."
|
|
|
|
sqlite3 wakapi_testing.db < schema.sql
|
|
|
|
|
|
|
|
echo "Importing seed data ..."
|
|
|
|
sqlite3 wakapi_testing.db < data.sql
|
|
|
|
|
|
|
|
echo "Running Wakapi testing instance in background ..."
|
2021-09-17 14:21:09 +03:00
|
|
|
../wakapi -config config.testing.yml &
|
|
|
|
pid=$!
|
2021-05-28 18:13:28 +03:00
|
|
|
|
|
|
|
echo "Waiting for Wakapi to come up ..."
|
|
|
|
until $(curl --output /dev/null --silent --get --fail http://localhost:3000/api/health); do
|
|
|
|
printf '.'
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
echo "Running test collection ..."
|
2022-02-17 14:20:22 +03:00
|
|
|
newman run "wakapi_api_tests.postman_collection.json"
|
2021-09-18 15:24:16 +03:00
|
|
|
exit_code=$?
|
2021-05-28 18:13:28 +03:00
|
|
|
|
|
|
|
echo "Shutting down Wakapi ..."
|
2021-09-17 14:21:09 +03:00
|
|
|
kill -TERM $pid
|
2021-05-28 18:13:28 +03:00
|
|
|
|
|
|
|
echo "Deleting database ..."
|
2021-09-18 15:24:16 +03:00
|
|
|
rm wakapi_testing.db
|
|
|
|
|
2022-02-17 14:20:22 +03:00
|
|
|
exit $exit_code
|