Jobley / app · jobley.ai / scripts / test-api.sh
| 1 | #!/usr/bin/env bash |
| 2 | # Runs the JobleyKit tests against the real API code: starts jobley-site's dev server on a fresh |
| 3 | # in-memory database with the five sample jobs, points the tests at it, then stops it. |
| 4 | # SITE=~/Documents/GIT_SOURCE/jobley-site scripts/test-api.sh |
| 5 | set -euo pipefail |
| 6 | SITE=${SITE:-"$HOME/Documents/GIT_SOURCE/jobley-site"} |
| 7 | PORT=${PORT:-8790} |
| 8 | TOKEN=dev-admin-token-not-for-production-0000 |
| 9 | (cd "$SITE" && PORT=$PORT DB_FILE=:memory: exec node --experimental-sqlite tools/dev-server.mjs --seed) > /tmp/jobley-test-server.log 2>&1 & |
| 10 | SERVER=$! |
| 11 | trap 'kill $SERVER 2>/dev/null' EXIT |
| 12 | for _ in $(seq 1 50); do curl -sf "http://localhost:$PORT/api/meta" >/dev/null && break; sleep 0.2; done |
| 13 | JOBLEY_TEST_BASE="http://localhost:$PORT" JOBLEY_TEST_TOKEN=$TOKEN swift test "$@" |