diff --git a/test_api.sh b/test_api.sh new file mode 100644 index 0000000..2f68222 --- /dev/null +++ b/test_api.sh @@ -0,0 +1,43 @@ +#!/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!"