Fix test api
This commit is contained in:
61
test_api.sh
61
test_api.sh
@@ -1,43 +1,54 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Basic API Tests for Event Store
|
||||
echo "🚀 Testing Event Store API..."
|
||||
# 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
|
||||
curl -s "$BASE_URL/api/health"
|
||||
echo
|
||||
|
||||
echo -e "\n2. Get current state"
|
||||
curl -s "$BASE_URL/api/state" | echo
|
||||
echo "2. 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" \
|
||||
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
|
||||
-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" \
|
||||
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
|
||||
-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 "5. 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" \
|
||||
echo "6. Add another field - single operation"
|
||||
curl -X PATCH "$BASE_URL/api/collections/shopping_items/items/test12345678901" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"seq": 0, "hash": ""}' | echo
|
||||
-d '{"op": "add", "path": "/priority", "value": "high"}'
|
||||
echo
|
||||
|
||||
echo -e "\n8. Soft delete the item"
|
||||
curl -X PATCH "$BASE_URL/api/collections/shopping_items/items/test123456789abc" \
|
||||
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": "add", "path": "/deleted_at", "value": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}]' | echo
|
||||
-d '{"op": "remove", "path": "/priority"}'
|
||||
echo
|
||||
|
||||
echo -e "\n9. Verify item is soft deleted"
|
||||
curl -s "$BASE_URL/api/items/shopping_items" | 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 -e "\n✅ API tests completed!"
|
||||
echo "9. Final state"
|
||||
curl -s "$BASE_URL/api/items/shopping_items"
|
||||
echo
|
||||
|
||||
echo "✅ Simple API tests completed!"
|
||||
|
Reference in New Issue
Block a user