-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·44 lines (35 loc) · 1.2 KB
/
test.sh
File metadata and controls
executable file
·44 lines (35 loc) · 1.2 KB
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
#!/bin/bash
set -e
function finish {
docker stop contentjet-api-test > /dev/null
}
trap finish EXIT
tsc=./node_modules/.bin/tsc
knex=./node_modules/.bin/knex
mocha=./node_modules/.bin/mocha
export NODE_ENV=test
export SECRET_KEY=%%%%TEST%%%%
export MAIL_FROM=noreply@example.com
export DEBUG=0
export POSTGRES_HOST=localhost
export POSTGRES_PORT=5431
export POSTGRES_DB=contentjet-api-test
export POSTGRES_PASSWORD=testpassword
if ! bash -c "docker start contentjet-api-test" 2> /dev/null;
then
echo "Test database container doesn't exist, creating."
docker run --name contentjet-api-test -p $POSTGRES_PORT:5432 -d -e POSTGRES_DB=$POSTGRES_DB -e POSTGRES_PASSWORD=$POSTGRES_PASSWORD postgres:9.6.2
else
echo "Test database container found!"
fi
$tsc
until $knex --knexfile dist/knexfile.js migrate:latest; do
>&2 echo "**********************************"
>&2 echo "Postgres is unavailable - sleeping"
>&2 echo "**********************************"
sleep 1
done
node dist/scripts/create-permissions.js
# Note the --exit flag is a workaround to prevent the process hanging. This requires further investigation.
# https://boneskull.com/mocha-v4-nears-release/#mochawontforceexit
$mocha --exit dist/**/*.test.js