Files
llm-intelligence/scripts/verify_t34.sh

41 lines
1.4 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# verify_t34.sh — 验收 T-3.4:前端 fixture JSON 接入与回退层
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
FILE="$PROJECT_ROOT/frontend/src/lib/models.ts"
JSON="$PROJECT_ROOT/frontend/src/data/models.json"
echo "=== T-3.4 验收检查 ==="
# T-3.4.1: JSON schema 验证
python3 -c "
import json
d=json.load(open('$JSON'))
assert all(k in d for k in ['generated_at','total','free','paid','models']), 'missing top keys'
assert all('pricing' in m and 'input' in m['pricing'] and 'output' in m['pricing'] for m in d['models']), 'missing pricing fields'
print('json-schema OK')
" && echo "json-schema PASS — JSON 含 generated_at/total/free/paid/models且 models 含 pricing.input/output" \
|| { echo "json-schema FAIL"; exit 1; }
# T-3.4.2: 前端具备 normalizeModel 映射函数
if grep -q 'normalizeModel' "$FILE"; then
echo "mapping PASS — normalizeModel 映射函数存在"
else
echo "mapping FAIL"
exit 1
fi
# T-3.4.3: fixture fallback 从 models.json 加载,而不是页面内硬编码 mock 数据
if grep -q "models.json" "$FILE" && \
! grep -q "provider.*OpenAI\|provider.*Anthropic\|provider.*DeepSeek" "$FILE"; then
echo "import PASS — 回退层引用 models.json无页面内硬编码 mock 数据"
else
echo "import FAIL — 仍有硬编码 mock 数据"
exit 1
fi
echo ""
echo "all PASS"
exit 0