Mercurial
diff seobeo/tests/seobeo_sse_server_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 |
line wrap: on
line diff
--- a/seobeo/tests/seobeo_sse_server_test.c Wed Aug 05 09:19:41 2026 -0700 +++ b/seobeo/tests/seobeo_sse_server_test.c Wed Aug 05 09:19:41 2026 -0700 @@ -62,17 +62,27 @@ return socket_fd; } -static void send_request(int socket_fd, const char *path) +static void send_request( + int socket_fd, + const char *method, + const char *path, + const char *body) { char request[512]; + size_t body_length = body ? strlen(body) : 0; int length = snprintf( request, sizeof(request), - "GET %s HTTP/1.1\r\n" + "%s %s HTTP/1.1\r\n" "Host: 127.0.0.1\r\n" + "Content-Length: %zu\r\n" "Connection: keep-alive\r\n" - "\r\n", - path); + "\r\n" + "%s", + method, + path, + body_length, + body ? body : ""); assert(length > 0 && (size_t)length < sizeof(request)); assert(send(socket_fd, request, (size_t)length, 0) == length); } @@ -140,7 +150,7 @@ int event_socket = connect_to(port); assert(event_socket >= 0); - send_request(event_socket, "/events"); + send_request(event_socket, "GET", "/events", NULL); char events[4096] = {0}; receive_until( event_socket, @@ -151,15 +161,48 @@ assert(strstr(events, "Content-Type: text/event-stream\r\n")); assert(strstr(events, "data: connected\n\n")); + int post_socket = connect_to(port); + assert(post_socket >= 0); + send_request( + post_socket, + "POST", + "/events/builds", + "deploy=release"); + char post_events[4096] = {0}; + receive_until( + post_socket, + post_events, + sizeof(post_events), + "data: topic=builds body=deploy=release\n\n"); + assert(strstr(post_events, "HTTP/1.1 200 OK\r\n")); + assert(strstr(post_events, "Content-Type: text/event-stream\r\n")); + + int wrong_method_socket = connect_to(port); + assert(wrong_method_socket >= 0); + send_request( + wrong_method_socket, + "PUT", + "/events/builds", + NULL); + char wrong_method[1024] = {0}; + receive_until( + wrong_method_socket, + wrong_method, + sizeof(wrong_method), + "\r\n\r\n"); + assert(strstr(wrong_method, "HTTP/1.1 404 Not Found\r\n")); + int health_socket = connect_to(port); assert(health_socket >= 0); - send_request(health_socket, "/health"); + send_request(health_socket, "GET", "/health", NULL); assert(shutdown(health_socket, SHUT_WR) == 0); char health[1024] = {0}; receive_until(health_socket, health, sizeof(health), "\r\n\r\nok"); assert(strstr(health, "HTTP/1.1 200 OK\r\n")); close(health_socket); + close(wrong_method_socket); + close(post_socket); close(event_socket); kill(server, SIGTERM); waitpid(server, NULL, 0);