Skip to content

Commit 220cb0f

Browse files
milos85vasicclaude
andcommitted
Phase 7: Add comprehensive tests and challenge scripts for messaging integration
Testing Infrastructure: - Add GraphQL schema tests (40 tests): Type definitions, queries, mutations, resolvers - Add TOON transport tests (28 tests): HTTP transport, middleware, metrics, concurrency - Add messaging integration tests (22 tests): In-memory broker, pub/sub, batch operations Challenge Scripts (5 new challenges with 165 total tests): - messaging_rabbitmq_challenge.sh (25 tests): Broker implementation, DLQ, confirms - messaging_kafka_challenge.sh (30 tests): Producer/consumer, topics, batching - graphql_integration_challenge.sh (35 tests): Schema, queries, mutations, types - toon_protocol_challenge.sh (38 tests): Encoder/decoder, compression, transport - messaging_hybrid_challenge.sh (37 tests): Full integration validation All tests validate: - RabbitMQ and Kafka broker implementations - GraphQL API with query/mutation support - TOON protocol for token-efficient AI communication - LLMsVerifier event system integration - Docker infrastructure configuration Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e73e990 commit 220cb0f

File tree

8 files changed

+2800
-0
lines changed

8 files changed

+2800
-0
lines changed
Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
#!/bin/bash
2+
# graphql_integration_challenge.sh - GraphQL Integration Challenge
3+
# Tests GraphQL API implementation for HelixAgent
4+
5+
set -e
6+
7+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
9+
source "$SCRIPT_DIR/common.sh"
10+
11+
CHALLENGE_NAME="GraphQL Integration Challenge"
12+
PASSED=0
13+
FAILED=0
14+
TOTAL=0
15+
16+
log_test() {
17+
local test_name="$1"
18+
local status="$2"
19+
TOTAL=$((TOTAL + 1))
20+
if [ "$status" = "PASS" ]; then
21+
PASSED=$((PASSED + 1))
22+
echo -e " \e[32m✓\e[0m $test_name"
23+
else
24+
FAILED=$((FAILED + 1))
25+
echo -e " \e[31m✗\e[0m $test_name"
26+
fi
27+
}
28+
29+
echo "=============================================="
30+
echo " $CHALLENGE_NAME"
31+
echo "=============================================="
32+
echo ""
33+
34+
cd "$PROJECT_ROOT"
35+
36+
# Test 1: GraphQL package structure
37+
echo "[1] GraphQL Package Structure"
38+
if [ -f "internal/graphql/schema.go" ]; then
39+
log_test "schema.go exists" "PASS"
40+
else
41+
log_test "schema.go exists" "FAIL"
42+
fi
43+
44+
if [ -f "internal/graphql/schema_test.go" ]; then
45+
log_test "schema_test.go exists" "PASS"
46+
else
47+
log_test "schema_test.go exists" "FAIL"
48+
fi
49+
50+
if [ -d "internal/graphql/types" ]; then
51+
log_test "types directory exists" "PASS"
52+
else
53+
log_test "types directory exists" "FAIL"
54+
fi
55+
56+
if [ -f "internal/graphql/types/types.go" ]; then
57+
log_test "types/types.go exists" "PASS"
58+
else
59+
log_test "types/types.go exists" "FAIL"
60+
fi
61+
62+
# Test 2: Schema types defined
63+
echo ""
64+
echo "[2] Schema Types"
65+
if grep -q "QueryType" internal/graphql/schema.go 2>/dev/null; then
66+
log_test "QueryType defined" "PASS"
67+
else
68+
log_test "QueryType defined" "FAIL"
69+
fi
70+
71+
if grep -q "MutationType" internal/graphql/schema.go 2>/dev/null; then
72+
log_test "MutationType defined" "PASS"
73+
else
74+
log_test "MutationType defined" "FAIL"
75+
fi
76+
77+
if grep -q "providerType" internal/graphql/schema.go 2>/dev/null; then
78+
log_test "providerType defined" "PASS"
79+
else
80+
log_test "providerType defined" "FAIL"
81+
fi
82+
83+
if grep -q "debateType" internal/graphql/schema.go 2>/dev/null; then
84+
log_test "debateType defined" "PASS"
85+
else
86+
log_test "debateType defined" "FAIL"
87+
fi
88+
89+
if grep -q "taskType" internal/graphql/schema.go 2>/dev/null; then
90+
log_test "taskType defined" "PASS"
91+
else
92+
log_test "taskType defined" "FAIL"
93+
fi
94+
95+
# Test 3: Query fields
96+
echo ""
97+
echo "[3] Query Fields"
98+
if grep -q '"providers"' internal/graphql/schema.go 2>/dev/null; then
99+
log_test "providers query field" "PASS"
100+
else
101+
log_test "providers query field" "FAIL"
102+
fi
103+
104+
if grep -q '"debates"' internal/graphql/schema.go 2>/dev/null; then
105+
log_test "debates query field" "PASS"
106+
else
107+
log_test "debates query field" "FAIL"
108+
fi
109+
110+
if grep -q '"tasks"' internal/graphql/schema.go 2>/dev/null; then
111+
log_test "tasks query field" "PASS"
112+
else
113+
log_test "tasks query field" "FAIL"
114+
fi
115+
116+
if grep -q '"verificationResults"' internal/graphql/schema.go 2>/dev/null; then
117+
log_test "verificationResults query field" "PASS"
118+
else
119+
log_test "verificationResults query field" "FAIL"
120+
fi
121+
122+
if grep -q '"providerScores"' internal/graphql/schema.go 2>/dev/null; then
123+
log_test "providerScores query field" "PASS"
124+
else
125+
log_test "providerScores query field" "FAIL"
126+
fi
127+
128+
# Test 4: Mutation fields
129+
echo ""
130+
echo "[4] Mutation Fields"
131+
if grep -q '"createDebate"' internal/graphql/schema.go 2>/dev/null; then
132+
log_test "createDebate mutation" "PASS"
133+
else
134+
log_test "createDebate mutation" "FAIL"
135+
fi
136+
137+
if grep -q '"submitDebateResponse"' internal/graphql/schema.go 2>/dev/null; then
138+
log_test "submitDebateResponse mutation" "PASS"
139+
else
140+
log_test "submitDebateResponse mutation" "FAIL"
141+
fi
142+
143+
if grep -q '"createTask"' internal/graphql/schema.go 2>/dev/null; then
144+
log_test "createTask mutation" "PASS"
145+
else
146+
log_test "createTask mutation" "FAIL"
147+
fi
148+
149+
if grep -q '"cancelTask"' internal/graphql/schema.go 2>/dev/null; then
150+
log_test "cancelTask mutation" "PASS"
151+
else
152+
log_test "cancelTask mutation" "FAIL"
153+
fi
154+
155+
if grep -q '"refreshProvider"' internal/graphql/schema.go 2>/dev/null; then
156+
log_test "refreshProvider mutation" "PASS"
157+
else
158+
log_test "refreshProvider mutation" "FAIL"
159+
fi
160+
161+
# Test 5: Input types
162+
echo ""
163+
echo "[5] Input Types"
164+
if grep -q "providerFilterInput" internal/graphql/schema.go 2>/dev/null; then
165+
log_test "ProviderFilter input type" "PASS"
166+
else
167+
log_test "ProviderFilter input type" "FAIL"
168+
fi
169+
170+
if grep -q "createDebateInput" internal/graphql/schema.go 2>/dev/null; then
171+
log_test "CreateDebateInput type" "PASS"
172+
else
173+
log_test "CreateDebateInput type" "FAIL"
174+
fi
175+
176+
if grep -q "createTaskInput" internal/graphql/schema.go 2>/dev/null; then
177+
log_test "CreateTaskInput type" "PASS"
178+
else
179+
log_test "CreateTaskInput type" "FAIL"
180+
fi
181+
182+
# Test 6: Resolvers
183+
echo ""
184+
echo "[6] Resolvers"
185+
if grep -q "ResolveProviders" internal/graphql/schema.go 2>/dev/null; then
186+
log_test "ResolveProviders resolver" "PASS"
187+
else
188+
log_test "ResolveProviders resolver" "FAIL"
189+
fi
190+
191+
if grep -q "ResolveDebates" internal/graphql/schema.go 2>/dev/null; then
192+
log_test "ResolveDebates resolver" "PASS"
193+
else
194+
log_test "ResolveDebates resolver" "FAIL"
195+
fi
196+
197+
if grep -q "ResolveTasks" internal/graphql/schema.go 2>/dev/null; then
198+
log_test "ResolveTasks resolver" "PASS"
199+
else
200+
log_test "ResolveTasks resolver" "FAIL"
201+
fi
202+
203+
if grep -q "ResolveCreateDebate" internal/graphql/schema.go 2>/dev/null; then
204+
log_test "ResolveCreateDebate resolver" "PASS"
205+
else
206+
log_test "ResolveCreateDebate resolver" "FAIL"
207+
fi
208+
209+
# Test 7: Schema initialization
210+
echo ""
211+
echo "[7] Schema Initialization"
212+
if grep -q "InitSchema" internal/graphql/schema.go 2>/dev/null; then
213+
log_test "InitSchema function" "PASS"
214+
else
215+
log_test "InitSchema function" "FAIL"
216+
fi
217+
218+
if grep -q "ExecuteQuery" internal/graphql/schema.go 2>/dev/null; then
219+
log_test "ExecuteQuery function" "PASS"
220+
else
221+
log_test "ExecuteQuery function" "FAIL"
222+
fi
223+
224+
# Test 8: Types package
225+
echo ""
226+
echo "[8] Types Package"
227+
if grep -q "type Provider struct" internal/graphql/types/types.go 2>/dev/null; then
228+
log_test "Provider struct" "PASS"
229+
else
230+
log_test "Provider struct" "FAIL"
231+
fi
232+
233+
if grep -q "type Model struct" internal/graphql/types/types.go 2>/dev/null; then
234+
log_test "Model struct" "PASS"
235+
else
236+
log_test "Model struct" "FAIL"
237+
fi
238+
239+
if grep -q "type Debate struct" internal/graphql/types/types.go 2>/dev/null; then
240+
log_test "Debate struct" "PASS"
241+
else
242+
log_test "Debate struct" "FAIL"
243+
fi
244+
245+
if grep -q "type Task struct" internal/graphql/types/types.go 2>/dev/null; then
246+
log_test "Task struct" "PASS"
247+
else
248+
log_test "Task struct" "FAIL"
249+
fi
250+
251+
if grep -q "type VerificationResults struct" internal/graphql/types/types.go 2>/dev/null; then
252+
log_test "VerificationResults struct" "PASS"
253+
else
254+
log_test "VerificationResults struct" "FAIL"
255+
fi
256+
257+
# Test 9: Unit tests
258+
echo ""
259+
echo "[9] Unit Tests"
260+
if go test -v ./internal/graphql/... -count=1 2>&1 | grep -q "PASS"; then
261+
log_test "GraphQL unit tests pass" "PASS"
262+
else
263+
log_test "GraphQL unit tests pass" "FAIL"
264+
fi
265+
266+
# Test 10: graphql-go dependency
267+
echo ""
268+
echo "[10] Dependencies"
269+
if grep -q "graphql-go/graphql" go.mod 2>/dev/null; then
270+
log_test "graphql-go in go.mod" "PASS"
271+
else
272+
log_test "graphql-go in go.mod" "FAIL"
273+
fi
274+
275+
echo ""
276+
echo "=============================================="
277+
echo " Results: $PASSED/$TOTAL tests passed"
278+
echo "=============================================="
279+
280+
if [ $FAILED -gt 0 ]; then
281+
echo -e "\e[31m$FAILED test(s) failed\e[0m"
282+
exit 1
283+
else
284+
echo -e "\e[32mAll tests passed!\e[0m"
285+
exit 0
286+
fi

0 commit comments

Comments
 (0)