44 lines
1.4 KiB
Bash
44 lines
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
# Basic API Tests for Event Store
|
|
echo "🚀 Testing Event Store API..."
|
|
|
|
BASE_URL="http://localhost:8090"
|
|
|
|
echo "1. Check server health"
|
|
curl -s "$BASE_URL/api/health" | echo
|
|
|
|
echo -e "\n2. Get current state"
|
|
curl -s "$BASE_URL/api/state" | echo
|
|
|
|
echo -e "\n3. Create an item via JSON Patch"
|
|
curl -X PATCH "$BASE_URL/api/collections/shopping_items/items/test123456789abc" \
|
|
-H "Content-Type: application/json" \
|
|
-d '[{"op": "add", "path": "/content", "value": "My test item"}]' | echo
|
|
|
|
echo -e "\n4. Update the item"
|
|
curl -X PATCH "$BASE_URL/api/collections/shopping_items/items/test123456789abc" \
|
|
-H "Content-Type: application/json" \
|
|
-d '[{"op": "replace", "path": "/content", "value": "Updated test item"}]' | echo
|
|
|
|
echo -e "\n5. Get all items"
|
|
curl -s "$BASE_URL/api/items/shopping_items" | echo
|
|
|
|
echo -e "\n6. Get current state again"
|
|
curl -s "$BASE_URL/api/state" | echo
|
|
|
|
echo -e "\n7. Sync test"
|
|
curl -X POST "$BASE_URL/api/sync" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"seq": 0, "hash": ""}' | echo
|
|
|
|
echo -e "\n8. Soft delete the item"
|
|
curl -X PATCH "$BASE_URL/api/collections/shopping_items/items/test123456789abc" \
|
|
-H "Content-Type: application/json" \
|
|
-d '[{"op": "add", "path": "/deleted_at", "value": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}]' | echo
|
|
|
|
echo -e "\n9. Verify item is soft deleted"
|
|
curl -s "$BASE_URL/api/items/shopping_items" | echo
|
|
|
|
echo -e "\n✅ API tests completed!"
|