Skip to content

Comments

test(gateway): add unit tests for HealthHandlers#232

Open
eclipse0922 wants to merge 4 commits intoselfpatch:mainfrom
eclipse0922:feat/issue-177-health-handlers-tests
Open

test(gateway): add unit tests for HealthHandlers#232
eclipse0922 wants to merge 4 commits intoselfpatch:mainfrom
eclipse0922:feat/issue-177-health-handlers-tests

Conversation

@eclipse0922
Copy link
Contributor

Summary

  • Adds 14 unit tests for HealthHandlers (handle_health, handle_root, handle_version_info)
  • Tests verify response body structure: status/timestamp fields, SOVD sovd_info array, vendor_info, endpoint list, capabilities
  • Tests auth-disabled behavior (no auth endpoints in list, capabilities.authentication=false) and auth-enabled behavior (auth endpoints appear)
  • Uses null GatewayNode and null AuthManager — safe because none of these handlers call ctx_.node() or ctx_.auth_manager()
  • Adds test_health_handlers to CMakeLists.txt with coverage support

Test plan

  • All 14 tests pass: colcon test --ctest-args -R test_health_handlers
  • Verified in Docker with ros2_medkit_dev:latest

Closes #177

🤖 Generated with Claude Code

eclipse0922 and others added 2 commits February 24, 2026 21:44
Adds 14 unit tests covering the three HealthHandlers methods:
- handle_health: verifies status field, timestamp, valid JSON body
- handle_version_info: verifies sovd_info array, version, base_uri, vendor_info
- handle_root: verifies required fields, endpoints list, capabilities,
  auth-disabled behavior (no auth endpoints, capabilities.authentication=false),
  and auth-enabled behavior (auth endpoints appear in list)

Uses a null GatewayNode and null AuthManager, which is safe because
none of these handler methods call ctx_.node() or ctx_.auth_manager().

Closes selfpatch#177

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds dedicated GTest coverage for the gateway’s simplest REST handlers (HealthHandlers), improving confidence in the /health, /, and /version-info responses and ensuring auth/tls capability reporting remains correct.

Changes:

  • Added 14 unit tests validating JSON structure and key fields for handle_health, handle_root, and handle_version_info.
  • Added auth-disabled vs auth-enabled expectations for endpoint listing and capabilities in root response.
  • Registered the new test target in CMakeLists.txt, including coverage flags wiring.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/ros2_medkit_gateway/test/test_health_handlers.cpp New unit test suite covering health/root/version-info handler response schemas and capability toggles.
src/ros2_medkit_gateway/CMakeLists.txt Adds test_health_handlers target and includes it in coverage instrumentation list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit tests for HealthHandlers

1 participant