test(cpp/core): integration tests for http_request + http_get_json (issue 0110)

Catch2-based tests that fork+exec a local python3 http.server fixture per
test binary. Covers:

  http_request:
    - GET 200 with body
    - GET 404 (HTTP error != transport error)
    - POST with body + Content-Type
    - bearer_token shortcut adds Authorization: Bearer
    - basic_user/basic_pass shortcut adds HTTP Basic (curl --user)
    - invalid URL surfaces transport error (status=0)
    - timeout_ms is honored (bails before server's 3s sleep)

  http_get_json:
    - parses 200 JSON body
    - throws std::runtime_error on 404
    - bearer_token reaches server (verified via echoed Authorization header)
    - throws std::runtime_error on invalid JSON body

Tests skip gracefully if python3 isn't available (server.start() returns
false; SUCCEED with skip message). No external network required.

Local runs (Linux): 21 assertions / 7 cases (http_request), 6 / 4 (get_json),
all passing.
This commit is contained in:
2026-05-18 18:14:48 +02:00
parent a3a263702b
commit 6f3c129a14
3 changed files with 389 additions and 0 deletions
+13
View File
@@ -256,6 +256,19 @@ add_fn_test(test_tql_to_sql test_tql_to_sql.cpp
add_fn_test(test_llm_anthropic test_llm_anthropic.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../functions/core/llm_anthropic.cpp)
# --- Issue 0110 — http_request: generic cURL-popen client -------------------
# Integration test: fork+execs python3 -m http.server fixture in the test
# process. Skips gracefully if python3 isn't available (server().pid == 0).
add_fn_test(test_http_request test_http_request.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../functions/core/http_request.cpp)
# --- Issue 0110 — http_get_json: nlohmann::json wrapper over http_request ---
add_fn_test(test_http_get_json test_http_get_json.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../functions/core/http_request.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../functions/core/http_get_json.cpp)
target_include_directories(test_http_get_json PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../vendor)
# --- Visual golden-image diff (issue 0048) ---------------------------------
# El binario primitives_gallery se compila con --capture; el test compara los
# PNGs generados con los goldens en cpp/tests/golden/. Si no hay goldens o el