You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
3.1 KiB
Bash
77 lines
3.1 KiB
Bash
#!/bin/bash
|
|
|
|
# Script de testes locais
|
|
# Testa a API antes de fazer deploy
|
|
|
|
set -e
|
|
|
|
API_URL=${1:-http://localhost:8000}
|
|
|
|
echo "🧪 Iniciando testes da API"
|
|
echo "🎯 URL: $API_URL"
|
|
echo ""
|
|
|
|
# Função para teste HTTP
|
|
test_endpoint() {
|
|
local method=$1
|
|
local endpoint=$2
|
|
local data=$3
|
|
local description=$4
|
|
|
|
echo "📝 Teste: $description"
|
|
echo " $method $endpoint"
|
|
|
|
if [ -z "$data" ]; then
|
|
curl -s -X $method "$API_URL$endpoint" \
|
|
-H "Content-Type: application/json" | jq . || echo "❌ Erro"
|
|
else
|
|
echo " Dados: $data"
|
|
curl -s -X $method "$API_URL$endpoint" \
|
|
-H "Content-Type: application/json" \
|
|
-d "$data" | jq . || echo "❌ Erro"
|
|
fi
|
|
echo ""
|
|
}
|
|
|
|
# Teste 1: Health check (Swagger)
|
|
echo "═══════════════════════════════════════════════════════════"
|
|
test_endpoint "GET" "/docs" "" "Documentação Swagger"
|
|
|
|
# Teste 2: Chat simples
|
|
echo "═══════════════════════════════════════════════════════════"
|
|
test_endpoint "POST" "/chat" \
|
|
'{"message":"Olá, tudo bem?","user_id":"test-user-1"}' \
|
|
"Chat simples (sem tool)"
|
|
|
|
# Teste 3: Chat com ferramenta - Consultar Estoque
|
|
echo "═══════════════════════════════════════════════════════════"
|
|
test_endpoint "POST" "/chat" \
|
|
'{"message":"Quero um carro de até 50000 reais que seja sedan","user_id":"test-user-2"}' \
|
|
"Chat com tool - Consultar Estoque"
|
|
|
|
# Teste 4: Chat com ferramenta - Validar Cliente
|
|
echo "═══════════════════════════════════════════════════════════"
|
|
test_endpoint "POST" "/chat" \
|
|
'{"message":"Meu CPF é 12345678900 e quero financiar um carro de 45000 reais, posso?","user_id":"test-user-3"}' \
|
|
"Chat com tool - Validar Cliente Venda"
|
|
|
|
# Teste 5: Chat com ferramenta - Avaliar Veículo
|
|
echo "═══════════════════════════════════════════════════════════"
|
|
test_endpoint "POST" "/chat" \
|
|
'{"message":"Tenho um Toyota Corolla 2015 com 120000 km, quanto vale para troca?","user_id":"test-user-4"}' \
|
|
"Chat com tool - Avaliar Veículo Troca"
|
|
|
|
# Teste 6: Mockaroo direto
|
|
echo "═══════════════════════════════════════════════════════════"
|
|
test_endpoint "POST" "/mock/consultar-estoque" \
|
|
'{"preco_max":50000,"categoria":"Sedan"}' \
|
|
"Endpoint direto - Consultar Estoque"
|
|
|
|
echo "✅ Testes concluídos!"
|
|
echo ""
|
|
echo "💡 Dicas:"
|
|
echo " - Para testes mais detalhados, visite: $API_URL/docs"
|
|
echo " - Para ver os logs: tail -f app.log"
|
|
echo " - Para reiniciar: Ctrl+C e execute novamente"
|
|
|