From 607dd465a7dd39dd0d254bf85491b7553970d206 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Mon, 29 Sep 2025 10:25:25 +0200 Subject: [PATCH] Fix test api --- test_api.sh | 61 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/test_api.sh b/test_api.sh index 2f68222..c2f8ed4 100644 --- a/test_api.sh +++ b/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!"