Separate out api url parser
This commit is contained in:
@@ -27,68 +27,6 @@ struct TestConnectionData {
|
||||
}
|
||||
};
|
||||
|
||||
TEST_CASE("HttpHandler route parsing") {
|
||||
SUBCASE("GET routes") {
|
||||
CHECK(HttpHandler::parseRoute("GET", "/v1/version") ==
|
||||
HttpRoute::GET_version);
|
||||
CHECK(HttpHandler::parseRoute("GET", "/v1/subscribe") ==
|
||||
HttpRoute::GET_subscribe);
|
||||
CHECK(HttpHandler::parseRoute("GET", "/v1/status") ==
|
||||
HttpRoute::GET_status);
|
||||
CHECK(HttpHandler::parseRoute("GET", "/v1/retention") ==
|
||||
HttpRoute::GET_retention);
|
||||
CHECK(HttpHandler::parseRoute("GET", "/metrics") == HttpRoute::GET_metrics);
|
||||
CHECK(HttpHandler::parseRoute("GET", "/ok") == HttpRoute::GET_ok);
|
||||
}
|
||||
|
||||
SUBCASE("POST routes") {
|
||||
CHECK(HttpHandler::parseRoute("POST", "/v1/commit") ==
|
||||
HttpRoute::POST_commit);
|
||||
}
|
||||
|
||||
SUBCASE("PUT routes") {
|
||||
CHECK(HttpHandler::parseRoute("PUT", "/v1/retention/policy1") ==
|
||||
HttpRoute::PUT_retention);
|
||||
}
|
||||
|
||||
SUBCASE("DELETE routes") {
|
||||
CHECK(HttpHandler::parseRoute("DELETE", "/v1/retention/policy1") ==
|
||||
HttpRoute::DELETE_retention);
|
||||
}
|
||||
|
||||
SUBCASE("Unknown routes") {
|
||||
CHECK(HttpHandler::parseRoute("GET", "/unknown") == HttpRoute::NotFound);
|
||||
CHECK(HttpHandler::parseRoute("PATCH", "/v1/version") ==
|
||||
HttpRoute::NotFound);
|
||||
}
|
||||
|
||||
SUBCASE("Query parameters stripped") {
|
||||
CHECK(HttpHandler::parseRoute("GET", "/v1/version?foo=bar") ==
|
||||
HttpRoute::GET_version);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("HttpHandler route parsing edge cases") {
|
||||
// Test just the static route parsing method since full integration testing
|
||||
// would require complex Connection setup with server dependencies
|
||||
|
||||
SUBCASE("Route parsing with query parameters") {
|
||||
CHECK(HttpHandler::parseRoute("GET", "/v1/version?param=value") ==
|
||||
HttpRoute::GET_version);
|
||||
CHECK(HttpHandler::parseRoute("GET", "/v1/subscribe?stream=true") ==
|
||||
HttpRoute::GET_subscribe);
|
||||
}
|
||||
|
||||
SUBCASE("Retention policy routes") {
|
||||
CHECK(HttpHandler::parseRoute("PUT", "/v1/retention/policy123") ==
|
||||
HttpRoute::PUT_retention);
|
||||
CHECK(HttpHandler::parseRoute("DELETE", "/v1/retention/policy456") ==
|
||||
HttpRoute::DELETE_retention);
|
||||
CHECK(HttpHandler::parseRoute("GET", "/v1/retention/policy789") ==
|
||||
HttpRoute::GET_retention);
|
||||
}
|
||||
}
|
||||
|
||||
// Test helper to verify the new hook functionality
|
||||
struct MockConnectionHandler : public ConnectionHandler {
|
||||
bool write_progress_called = false;
|
||||
|
||||
Reference in New Issue
Block a user