Fix test api
This commit is contained in:
61
test_api.sh
61
test_api.sh
@@ -1,43 +1,54 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Basic API Tests for Event Store
|
# Simple API Tests - ONE OPERATION PER REQUEST
|
||||||
echo "🚀 Testing Event Store API..."
|
echo "🚀 Testing Simple Event Store API..."
|
||||||
|
|
||||||
BASE_URL="http://localhost:8090"
|
BASE_URL="http://localhost:8090"
|
||||||
|
|
||||||
echo "1. Check server health"
|
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"
|
echo "2. Get current state"
|
||||||
curl -s "$BASE_URL/api/state" | echo
|
curl -s "$BASE_URL/api/state"
|
||||||
|
echo
|
||||||
|
|
||||||
echo -e "\n3. Create an item via JSON Patch"
|
echo "3. Create an item - single operation"
|
||||||
curl -X PATCH "$BASE_URL/api/collections/shopping_items/items/test123456789abc" \
|
curl -X PATCH "$BASE_URL/api/collections/shopping_items/items/test12345678901" \
|
||||||
-H "Content-Type: application/json" \
|
-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"
|
echo "4. Update the item - single operation"
|
||||||
curl -X PATCH "$BASE_URL/api/collections/shopping_items/items/test123456789abc" \
|
curl -X PATCH "$BASE_URL/api/collections/shopping_items/items/test12345678901" \
|
||||||
-H "Content-Type: application/json" \
|
-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"
|
echo "5. Get all items"
|
||||||
curl -s "$BASE_URL/api/items/shopping_items" | echo
|
curl -s "$BASE_URL/api/items/shopping_items"
|
||||||
|
echo
|
||||||
|
|
||||||
echo -e "\n6. Get current state again"
|
echo "6. Add another field - single operation"
|
||||||
curl -s "$BASE_URL/api/state" | echo
|
curl -X PATCH "$BASE_URL/api/collections/shopping_items/items/test12345678901" \
|
||||||
|
|
||||||
echo -e "\n7. Sync test"
|
|
||||||
curl -X POST "$BASE_URL/api/sync" \
|
|
||||||
-H "Content-Type: application/json" \
|
-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"
|
echo "7. Remove a field - single operation"
|
||||||
curl -X PATCH "$BASE_URL/api/collections/shopping_items/items/test123456789abc" \
|
curl -X PATCH "$BASE_URL/api/collections/shopping_items/items/test12345678901" \
|
||||||
-H "Content-Type: application/json" \
|
-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"
|
echo "8. Soft delete - single operation"
|
||||||
curl -s "$BASE_URL/api/items/shopping_items" | echo
|
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