#!/bin/bash
# test_api.sh - API接口测试脚本

API_URL=${API_URL:-http://localhost:8000}

echo "========================================"
echo "API接口测试"
echo "========================================"
echo ""

# 1. 健康检查
echo ">>> 测试: 健康检查 GET /health"
curl -s -X GET "$API_URL/health"
echo ""
echo ""

# 2. 根路径
echo ">>> 测试: 根路径 GET /"
curl -s -X GET "$API_URL/"
echo ""
echo ""

# 3. 检索接口（无数据时返回空结果）
echo ">>> 测试: 检索接口 POST /api/v1/knowledge/search"
curl -s -X POST "$API_URL/api/v1/knowledge/search" \
    -H "Content-Type: application/json" \
    -d '{"query": "机动车安全标准", "top_k": 5}'
echo ""
echo ""

echo "========================================"
echo "测试完成"
echo "========================================"
echo ""
echo "上传文档测试:"
echo "  ./test_upload.sh your_file.pdf"
echo ""