Files
Converge/scripts/test.sh

50 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Runs the API test suites against a dev server on :3500.
# Each suite starts from a freshly seeded knowledge base so runs are repeatable.
set -uo pipefail
cd "$(dirname "$0")/.."
BASE=http://127.0.0.1:3500
curl -sf "$BASE/api/catalog" -o /dev/null || { echo "Start the dev server first: npm run dev"; exit 1; }
reseed() {
rm -f data/knowledge-base.json
node scripts/seed-kb.mjs > /dev/null
}
fail=0
echo "=== dossier parser ==="
./scripts/build-test-lib.sh
node scripts/test-dossier.mjs || fail=1
echo
echo "=== financial engine, planner, scenarios, curation ==="
node scripts/test-finance.mjs || fail=1
echo
echo "=== knowledge base: learning ==="
reseed
node scripts/test-kb-learning.mjs || fail=1
echo
echo "=== knowledge base: pruning ==="
reseed
curl -s "$BASE/api/assessments/northwind-financial" > /tmp/prt-nw.json
curl -s -X PUT -H "Content-Type: application/json" -d @/tmp/prt-nw.json \
"$BASE/api/assessments/northwind-financial" -o /dev/null
node scripts/test-kb-pruning.mjs || fail=1
echo
echo "=== customer-report redaction ==="
node scripts/test-report-leak.mjs || fail=1
# Leave the knowledge base in a clean, fully-learned state.
reseed
curl -s -X PUT -H "Content-Type: application/json" -d @/tmp/prt-nw.json \
"$BASE/api/assessments/northwind-financial" -o /dev/null
echo
[ $fail -eq 0 ] && echo "All suites passed." || echo "Some suites failed."
exit $fail