|
| 1 | +# Testing Guide |
| 2 | + |
| 3 | +## 1. Build & Static Analysis |
| 4 | + |
| 5 | +```bash |
| 6 | +go build ./... |
| 7 | +go vet ./... |
| 8 | +``` |
| 9 | + |
| 10 | +## 2. Dry-Run Ingestion |
| 11 | + |
| 12 | +```bash |
| 13 | +go run cmd/ingest/main.go |
| 14 | +``` |
| 15 | + |
| 16 | +Expected output: |
| 17 | +- 11 documents loaded |
| 18 | +- ~158 chunks created |
| 19 | +- ~1485 unique TF-IDF terms |
| 20 | +- 158 non-zero embeddings |
| 21 | + |
| 22 | +## 3. Start the Server |
| 23 | + |
| 24 | +```bash |
| 25 | +go run cmd/server/main.go |
| 26 | +``` |
| 27 | + |
| 28 | +Expected startup logs: |
| 29 | +``` |
| 30 | +Starting Customer Support RAG Server... |
| 31 | +Loaded 11 documents |
| 32 | +Created 158 chunks |
| 33 | +Built TF-IDF vocabulary: 1485 terms |
| 34 | +Indexed 158 chunks in vector store |
| 35 | +Server starting on port 8080 |
| 36 | +``` |
| 37 | + |
| 38 | +## 4. Health Check |
| 39 | + |
| 40 | +```bash |
| 41 | +curl http://localhost:8080/api/health |
| 42 | +``` |
| 43 | + |
| 44 | +Expected: |
| 45 | +```json |
| 46 | +{"status":"healthy","active_sessions":0,"documents":158} |
| 47 | +``` |
| 48 | + |
| 49 | +## 5. Chat Queries |
| 50 | + |
| 51 | +### Basic question (no session) |
| 52 | + |
| 53 | +```bash |
| 54 | +curl -s -X POST http://localhost:8080/api/chat \ |
| 55 | + -H "Content-Type: application/json" \ |
| 56 | + -d '{"query": "How do I reset my password?"}' | jq . |
| 57 | +``` |
| 58 | + |
| 59 | +Verify: response has `session_id`, `answer`, and `sources` array. |
| 60 | + |
| 61 | +### Multi-turn conversation (reuse session) |
| 62 | + |
| 63 | +```bash |
| 64 | +# First message |
| 65 | +curl -s -X POST http://localhost:8080/api/chat \ |
| 66 | + -H "Content-Type: application/json" \ |
| 67 | + -d '{"query": "What pricing plans do you offer?"}' | jq . |
| 68 | + |
| 69 | +# Copy the session_id from the response, then: |
| 70 | +curl -s -X POST http://localhost:8080/api/chat \ |
| 71 | + -H "Content-Type: application/json" \ |
| 72 | + -d '{"query": "Which plan has the best value?", "session_id": "SESSION_ID_HERE"}' | jq . |
| 73 | +``` |
| 74 | + |
| 75 | +Verify: second response references context from the first turn. |
| 76 | + |
| 77 | +### Sample queries to test different knowledge areas |
| 78 | + |
| 79 | +```bash |
| 80 | +# Billing |
| 81 | +curl -s -X POST http://localhost:8080/api/chat \ |
| 82 | + -H "Content-Type: application/json" \ |
| 83 | + -d '{"query": "Do you offer a free trial?"}' | jq .answer |
| 84 | + |
| 85 | +# Technical |
| 86 | +curl -s -X POST http://localhost:8080/api/chat \ |
| 87 | + -H "Content-Type: application/json" \ |
| 88 | + -d '{"query": "How do I install the chat widget on my website?"}' | jq .answer |
| 89 | + |
| 90 | +# Integrations |
| 91 | +curl -s -X POST http://localhost:8080/api/chat \ |
| 92 | + -H "Content-Type: application/json" \ |
| 93 | + -d '{"query": "Can I connect Salesforce to CloudSupport Pro?"}' | jq .answer |
| 94 | + |
| 95 | +# Troubleshooting |
| 96 | +curl -s -X POST http://localhost:8080/api/chat \ |
| 97 | + -H "Content-Type: application/json" \ |
| 98 | + -d '{"query": "The chat widget is not showing on my site"}' | jq .answer |
| 99 | + |
| 100 | +# Out-of-scope (should gracefully decline) |
| 101 | +curl -s -X POST http://localhost:8080/api/chat \ |
| 102 | + -H "Content-Type: application/json" \ |
| 103 | + -d '{"query": "What is the weather today?"}' | jq .answer |
| 104 | +``` |
| 105 | + |
| 106 | +## 6. Error Cases |
| 107 | + |
| 108 | +### Empty query |
| 109 | + |
| 110 | +```bash |
| 111 | +curl -s -X POST http://localhost:8080/api/chat \ |
| 112 | + -H "Content-Type: application/json" \ |
| 113 | + -d '{"query": ""}' -w "\n%{http_code}" |
| 114 | +``` |
| 115 | + |
| 116 | +Expected: `400 Bad Request` |
| 117 | + |
| 118 | +### Wrong HTTP method |
| 119 | + |
| 120 | +```bash |
| 121 | +curl -s -X GET http://localhost:8080/api/chat -w "\n%{http_code}" |
| 122 | +``` |
| 123 | + |
| 124 | +Expected: `405 Method Not Allowed` |
| 125 | + |
| 126 | +### Invalid JSON |
| 127 | + |
| 128 | +```bash |
| 129 | +curl -s -X POST http://localhost:8080/api/chat \ |
| 130 | + -H "Content-Type: application/json" \ |
| 131 | + -d 'not json' -w "\n%{http_code}" |
| 132 | +``` |
| 133 | + |
| 134 | +Expected: `400 Bad Request` |
| 135 | + |
| 136 | +## 7. Graceful Shutdown |
| 137 | + |
| 138 | +With the server running, press `Ctrl+C`. Expected logs: |
| 139 | + |
| 140 | +``` |
| 141 | +Shutting down server... |
| 142 | +Shutdown complete |
| 143 | +``` |
0 commit comments