api/tests/smoke.sh
27 lines · 777 bytes
1#!/usr/bin/env bash
2# Boots the API and checks public routes respond, using only bundled data (no network)
3set -euo pipefail
4
5port="${PORT:-8787}"
6base="http://localhost:${port}"
7
8bun run build:data
9
10bun run start &
11server=$!
12trap 'kill "${server}" 2>/dev/null || true' EXIT
13
14# Wait for the server to accept connections
15for _ in $(seq 1 30); do
16 curl -fsS "${base}/v1/health" >/dev/null 2>&1 && break
17 sleep 1
18done
19
20health=$(curl -fsS "${base}/v1/health")
21echo "${health}" | grep -q '"status":"ok"' || { echo "❌ health check failed"; exit 1; }
22
23# Stats are derived from the bundled dataset, so this proves data loaded
24stats=$(curl -fsS "${base}/v1/stats")
25echo "${stats}" | grep -q '"categories"' || { echo "❌ stats check failed"; exit 1; }
26
27echo "✅ Smoke test passed"