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