Skip to content

Commit 336f1a9

Browse files
etrclaude
andcommitted
test(TASK-026): RED route() generic registration suite
Adds test/unit/webserver_route_test.cpp covering: - Compile-time signature contract for both new public overloads: route(http_method, const string&, std::function<...>) and route(method_set, const string&, std::function<...>) returning void. - Runtime curl tests for single-method route() (GET/POST), 405 with Allow header for unregistered methods, the headline acceptance test (load (method, path) pairs from a vector at runtime and dispatch via route()), method_set GET+HEAD both serve, method_set partial overlap with an existing handler throws atomically (POST stays unregistered), empty method_set throws, http_method::count_ sentinel throws, duplicate / cross-overload conflicts with on_* throw, parameterized path binds through the regex tier, empty std::function throws on either overload. Wires the new TU into test/Makefile.am (check_PROGRAMS + webserver_route_SOURCES). Build of the test currently fails to compile because webserver::route is missing -- this is the RED gate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 39c3c0d commit 336f1a9

2 files changed

Lines changed: 447 additions & 1 deletion

File tree

test/Makefile.am

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ LDADD += -lcurl
2626

2727
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/httpserver/ -DHTTPSERVER_COMPILATION
2828
METASOURCES = AUTO
29-
check_PROGRAMS = basic file_upload http_utils threaded nodelay string_utilities http_endpoint ban_system ws_start_stop authentication deferred http_resource http_response create_webserver new_response_types daemon_info uri_log feature_unavailable header_hygiene_iovec header_hygiene iovec_entry http_method constants body http_response_sbo http_response_factories webserver_pimpl http_request_pimpl create_test_request http_request_arena http_request_const_getters http_request_tls_accessors webserver_register_smartptr webserver_register_path_prefix webserver_on_methods
29+
check_PROGRAMS = basic file_upload http_utils threaded nodelay string_utilities http_endpoint ban_system ws_start_stop authentication deferred http_resource http_response create_webserver new_response_types daemon_info uri_log feature_unavailable header_hygiene_iovec header_hygiene iovec_entry http_method constants body http_response_sbo http_response_factories webserver_pimpl http_request_pimpl create_test_request http_request_arena http_request_const_getters http_request_tls_accessors webserver_register_smartptr webserver_register_path_prefix webserver_on_methods webserver_route
3030

3131
MOSTLYCLEANFILES = *.gcda *.gcno *.gcov
3232

@@ -182,6 +182,19 @@ webserver_register_path_prefix_SOURCES = unit/webserver_register_path_prefix_tes
182182
# sufficient.
183183
webserver_on_methods_SOURCES = unit/webserver_on_methods_test.cpp
184184

185+
# webserver_route: TASK-026. Compile-time signature contract for the two
186+
# generic route() overloads (route(http_method, ...) and
187+
# route(method_set, ...)) plus runtime curl tests covering: GET/POST
188+
# dispatch, 405 + Allow on unregistered methods, the headline acceptance
189+
# test (load (method, path) pairs from a vector at runtime and dispatch),
190+
# method_set GET+HEAD serves both, method_set partial overlap with an
191+
# existing handler throws atomically (POST stays unregistered), empty
192+
# method_set throws, http_method::count_ sentinel throws, duplicate /
193+
# cross-overload conflicts with on_* throw, and parameterized paths bind
194+
# through the regex tier. Default LDADD (libhttpserver + curl) is
195+
# sufficient.
196+
webserver_route_SOURCES = unit/webserver_route_test.cpp
197+
185198
noinst_HEADERS = littletest.hpp
186199
AM_CXXFLAGS += -Wall -fPIC -Wno-overloaded-virtual
187200

0 commit comments

Comments
 (0)