1#!/bin/bash
2
3# Manual test script for Shelley server
4# Usage: ./test_manual.sh [port]
5
6set -e
7
8PORT=${1:-8080}
9BASE_URL="http://localhost:$PORT"
10
11echo "=== Shelley Manual Test Script ==="
12echo "Testing server at $BASE_URL"
13echo
14
15# Function to make HTTP requests with better error handling
16make_request() {
17 local method=$1
18 local url=$2
19 local data=$3
20
21 echo "Making $method request to $url"
22 if [ -n "$data" ]; then
23 echo "Request body: $data"
24 fi
25
26 if [ -n "$data" ]; then
27 curl -s -X "$method" -H "Content-Type: application/json" -d "$data" "$url" || echo "Request failed"
28 else
29 curl -s -X "$method" "$url" || echo "Request failed"
30 fi
31
32 echo
33 echo "---"
34 echo
35}
36
37echo "1. Testing server health by listing conversations..."
38make_request "GET" "$BASE_URL/conversations"
39
40echo "2. Creating a test conversation..."
41echo " Note: This test assumes a conversation exists. If not, create one via the database or modify the server to auto-create."
42echo
43
44echo "3. Testing with a sample conversation ID (replace with real ID)..."
45echo " For a real test, first start the server, create a conversation via the database,"
46echo " then use that conversation ID in the following requests."
47echo
48echo " Example conversation creation (using sqlite3):"
49echo " sqlite3 shelley.db \"INSERT INTO conversations (conversation_id, slug) VALUES ('test-123', 'manual-test');\""
50echo
51echo " Then test chat:"
52echo " curl -X POST -H 'Content-Type: application/json' -d '{\"message\": \"Hello, how are you?\"}' $BASE_URL/conversation/test-123/chat"
53echo
54echo " And get messages:"
55echo " curl $BASE_URL/conversation/test-123"
56echo
57echo " And test streaming:"
58echo " curl $BASE_URL/conversation/test-123/stream"
59echo
60
61echo "4. Instructions for testing with Anthropic API:"
62echo " 1. Set ANTHROPIC_API_KEY environment variable with a valid key"
63echo " 2. Start server: cd cmd/shelley && ./shelley --port=$PORT"
64echo " 3. Create a conversation and send messages as shown above"
65echo
66
67echo "5. Testing server responsiveness..."
68echo " If server is running, this should return an empty conversations list:"
69make_request "GET" "$BASE_URL/conversations?limit=1"
70
71echo "=== Manual test complete ==="
72echo "For full testing with real conversations, use the commands shown above."