Files
event-driven-shoppinglist/test_api.sh
2025-09-29 12:22:01 +02:00

55 lines
1.7 KiB
Bash

#!/bin/bash
# Simple API Tests - ONE OPERATION PER REQUEST
echo "🚀 Testing Simple Event Store API..."
BASE_URL="http://localhost:8090"
echo "1. Check server health"
curl -s "$BASE_URL/api/health"
echo
echo "2. Get current state"
curl -s "$BASE_URL/api/state"
echo
echo "3. Create an item - single operation"
curl -X PATCH "$BASE_URL/api/collections/shopping_items/items/test12345678901" \
-H "Content-Type: application/json" \
-d "{\"op\": \"add\", \"path\": \"/content\", \"value\": \"My test item\"}"
echo
echo "4. Update the item - single operation"
curl -X PATCH "$BASE_URL/api/collections/shopping_items/items/test12345678901" \
-H "Content-Type: application/json" \
-d "{\"op\": \"replace\", \"path\": \"/content\", \"value\": \"Updated test item\"}"
echo
echo "5. Get all items"
curl -s "$BASE_URL/api/items/shopping_items"
echo
echo "6. Add another field - single operation"
curl -X PATCH "$BASE_URL/api/collections/shopping_items/items/test12345678901" \
-H "Content-Type: application/json" \
-d "{\"op\": \"add\", \"path\": \"/priority\", \"value\": \"high\"}"
echo
echo "7. Remove a field - single operation"
curl -X PATCH "$BASE_URL/api/collections/shopping_items/items/test12345678901" \
-H "Content-Type: application/json" \
-d "{\"op\": \"remove\", \"path\": \"/priority\"}"
echo
echo "8. Soft delete - single operation"
curl -X PATCH "$BASE_URL/api/collections/shopping_items/items/test12345678901" \
-H "Content-Type: application/json" \
-d "{\"op\": \"add\", \"path\": \"/deleted_at\", \"value\": \"2025-09-29T10:00:00Z\"}"
echo
echo "9. Final state"
curl -s "$BASE_URL/api/items/shopping_items"
echo
echo "✅ Simple API tests completed!"