aissia/tests/CMakeLists.txt
StillHammer 18f4f16213 feat: Add WebModule for HTTP requests via IIO
Implements WebModule that allows other modules to make HTTP requests
through IIO pub/sub messaging system.

Features:
- HTTP GET/POST support via existing HttpClient
- Request/response via IIO topics (web:request/web:response)
- Security: blocks localhost and private IPs
- Statistics tracking (total, success, failed)
- Hot-reload state preservation
- Custom headers and timeout configuration

Module architecture:
- WebModule.h/cpp: 296 lines total (within 300 line limit)
- config/web.json: Configuration file
- 10 integration tests (TI_WEB_001 to TI_WEB_010)

Tests: 120/120 passing (110 existing + 10 new)

Protocol:
- Subscribe: web:request
- Publish: web:response
- Request fields: requestId, url, method, headers, body, timeoutMs
- Response fields: requestId, success, statusCode, body, error, durationMs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 17:15:46 +08:00

109 lines
3.4 KiB
CMake

# ============================================================================
# AISSIA Integration Tests
# ============================================================================
# Fetch Catch2
include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.4.0
)
FetchContent_MakeAvailable(Catch2)
# ============================================================================
# Test executable
# ============================================================================
add_executable(aissia_tests
main.cpp
# Mocks
mocks/MockIO.cpp
# Module sources (needed for testing)
${CMAKE_SOURCE_DIR}/src/modules/SchedulerModule.cpp
${CMAKE_SOURCE_DIR}/src/modules/NotificationModule.cpp
${CMAKE_SOURCE_DIR}/src/modules/MonitoringModule.cpp
${CMAKE_SOURCE_DIR}/src/modules/AIModule.cpp
${CMAKE_SOURCE_DIR}/src/modules/VoiceModule.cpp
${CMAKE_SOURCE_DIR}/src/modules/StorageModule.cpp
${CMAKE_SOURCE_DIR}/src/modules/WebModule.cpp
# Module tests (70 TI)
modules/SchedulerModuleTests.cpp
modules/NotificationModuleTests.cpp
modules/MonitoringModuleTests.cpp
modules/AIModuleTests.cpp
modules/VoiceModuleTests.cpp
modules/StorageModuleTests.cpp
modules/WebModuleTests.cpp
# MCP tests (50 TI)
mcp/MCPTypesTests.cpp
mcp/StdioTransportTests.cpp
mcp/MCPClientTests.cpp
)
target_link_libraries(aissia_tests PRIVATE
Catch2::Catch2WithMain
GroveEngine::impl
AissiaTools
spdlog::spdlog
)
# WebModule needs httplib and OpenSSL
target_include_directories(aissia_tests PRIVATE
${httplib_SOURCE_DIR}
)
if(OPENSSL_FOUND)
target_link_libraries(aissia_tests PRIVATE OpenSSL::SSL OpenSSL::Crypto)
target_compile_definitions(aissia_tests PRIVATE CPPHTTPLIB_OPENSSL_SUPPORT)
endif()
# Disable module factory functions during testing
target_compile_definitions(aissia_tests PRIVATE AISSIA_TEST_BUILD)
target_include_directories(aissia_tests PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}
)
# ============================================================================
# Copy test fixtures to build directory
# ============================================================================
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/
DESTINATION ${CMAKE_BINARY_DIR}/tests/fixtures)
# ============================================================================
# CTest integration
# ============================================================================
include(CTest)
# Note: catch_discover_tests requires running the exe at build time
# which can fail due to missing DLLs. Use manual test registration instead.
add_test(NAME aissia_tests COMMAND aissia_tests)
# ============================================================================
# Custom targets
# ============================================================================
# Run all tests
add_custom_target(test_all
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
DEPENDS aissia_tests
COMMENT "Running all integration tests"
)
# Run module tests only
add_custom_target(test_modules
COMMAND $<TARGET_FILE:aissia_tests> "[scheduler],[notification],[monitoring],[ai],[voice],[storage],[web]"
DEPENDS aissia_tests
COMMENT "Running module integration tests"
)
# Run MCP tests only
add_custom_target(test_mcp
COMMAND $<TARGET_FILE:aissia_tests> "[mcp]"
DEPENDS aissia_tests
COMMENT "Running MCP integration tests"
)