comparison seobeo/tests/seobeo_sse_test.c @ 260:1f9877b637e9

Add Copilot-powered cyberpunk JRPG chat Integrate the production JRPG chat with Seobeo streaming, Deita persistence, and a Bazel-managed Copilot SDK and LiteLLM inference stack. Co-authored-by: Copilot <[email protected]>
author MrJuneJune <mrjunejune@users.noreply.github.com>
date Wed, 05 Aug 2026 09:19:41 -0700
parents 609d3c6aff4e
children 04fee26ecce0
comparison
equal deleted inserted replaced
259:667156fcd3e3 260:1f9877b637e9
28 assert(received == expected_length); 28 assert(received == expected_length);
29 assert(memcmp(buffer, expected, expected_length) == 0); 29 assert(memcmp(buffer, expected, expected_length) == 0);
30 } 30 }
31 31
32 static void route_handler( 32 static void route_handler(
33 Seobeo_SSE_Stream *p_stream,
34 Seobeo_Request_Entry *p_request,
35 Dowa_Arena *p_arena)
36 {
37 (void)p_stream;
38 (void)p_request;
39 (void)p_arena;
40 }
41
42 static void post_route_handler(
33 Seobeo_SSE_Stream *p_stream, 43 Seobeo_SSE_Stream *p_stream,
34 Seobeo_Request_Entry *p_request, 44 Seobeo_Request_Entry *p_request,
35 Dowa_Arena *p_arena) 45 Dowa_Arena *p_arena)
36 { 46 {
37 (void)p_stream; 47 (void)p_stream;
177 close(sockets[1]); 187 close(sockets[1]);
178 188
179 Seobeo_Router_Init(); 189 Seobeo_Router_Init();
180 Seobeo_Router_Register_SSE("/events/:topic", route_handler); 190 Seobeo_Router_Register_SSE("/events/:topic", route_handler);
181 Seobeo_Router_Register_SSE("/events/:topic/fixed", route_handler); 191 Seobeo_Router_Register_SSE("/events/:topic/fixed", route_handler);
192 Seobeo_Router_Register_SSE_Method(
193 "POST",
194 "/events/:topic",
195 post_route_handler);
182 Dowa_Arena *p_arena = Dowa_Arena_Create(4096); 196 Dowa_Arena *p_arena = Dowa_Arena_Create(4096);
183 Seobeo_Request_Entry *p_request = NULL; 197 Seobeo_Request_Entry *p_request = NULL;
184 Seobeo_SSE_Handler handler = Seobeo_Router_Find_SSE_Handler( 198 Seobeo_SSE_Handler handler = Seobeo_Router_Find_SSE_Handler(
185 "GET", 199 "GET",
186 "/events/builds", 200 "/events/builds",
189 assert(handler == route_handler); 203 assert(handler == route_handler);
190 Seobeo_Request_Entry *p_topic = Dowa_HashMap_Get_Ptr( 204 Seobeo_Request_Entry *p_topic = Dowa_HashMap_Get_Ptr(
191 p_request, 205 p_request,
192 ":topic"); 206 ":topic");
193 assert(p_topic && strcmp(p_topic->value, "builds") == 0); 207 assert(p_topic && strcmp(p_topic->value, "builds") == 0);
208 Seobeo_Request_Entry *p_post_request = NULL;
209 Dowa_HashMap_Push_Arena(
210 p_post_request,
211 "Body",
212 "deploy=release",
213 p_arena);
194 assert(Seobeo_Router_Find_SSE_Handler( 214 assert(Seobeo_Router_Find_SSE_Handler(
195 "POST", 215 "POST",
196 "/events/builds", 216 "/events/builds",
197 &p_request, 217 &p_post_request,
218 p_arena) == post_route_handler);
219 p_topic = Dowa_HashMap_Get_Ptr(p_post_request, ":topic");
220 Seobeo_Request_Entry *p_body = Dowa_HashMap_Get_Ptr(
221 p_post_request,
222 "Body");
223 assert(p_topic && strcmp(p_topic->value, "builds") == 0);
224 assert(p_body && strcmp(p_body->value, "deploy=release") == 0);
225 Seobeo_Request_Entry *p_wrong_method = NULL;
226 assert(Seobeo_Router_Find_SSE_Handler(
227 "PUT",
228 "/events/builds",
229 &p_wrong_method,
198 p_arena) == NULL); 230 p_arena) == NULL);
231 assert(Dowa_HashMap_Get_Ptr(p_wrong_method, ":topic") == NULL);
199 Seobeo_Request_Entry *p_unmatched = NULL; 232 Seobeo_Request_Entry *p_unmatched = NULL;
200 assert(Seobeo_Router_Find_SSE_Handler( 233 assert(Seobeo_Router_Find_SSE_Handler(
201 "GET", 234 "GET",
202 "/events/builds/other", 235 "/events/builds/other",
203 &p_unmatched, 236 &p_unmatched,