Skip to content

Comments

test(gateway): add unit tests for DataHandlers#234

Open
eclipse0922 wants to merge 2 commits intoselfpatch:mainfrom
eclipse0922:feat/issue-180-data-handlers-tests
Open

test(gateway): add unit tests for DataHandlers#234
eclipse0922 wants to merge 2 commits intoselfpatch:mainfrom
eclipse0922:feat/issue-180-data-handlers-tests

Conversation

@eclipse0922
Copy link
Contributor

@eclipse0922 eclipse0922 commented Feb 24, 2026

Summary

  • Adds 17 unit tests for DataHandlers
  • handle_data_categories and handle_data_groups both return 501 with a SOVD-compliant error body (error_code: "not-implemented", message) per ISO 17978-3 §7.9, which is not yet implemented for ROS 2
  • Verifies both 501 endpoints return the same error_code and status code
  • handle_list_data, handle_get_data_item, handle_put_data_item each return 400 when req.matches is empty (missing route capture groups), verifying the guard check that runs before ctx_.node() is accessed
  • Tests use null GatewayNode and null AuthManager (safe: 501 handlers only call static HandlerContext::send_error(); other handlers check req.matches.size() before any node access)

Test plan

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

Closes #180

🤖 Generated with Claude Code

eclipse0922 and others added 2 commits February 24, 2026 21:50
Adds 13 unit tests covering DataHandlers methods:
- handle_data_categories and handle_data_groups both return 501 with
  a SOVD-compliant error body (error_code: "not-implemented", message)
  per ISO 17978-3 §7.9 which is not yet implemented for ROS 2
- Verifies both 501 endpoints return identical error_code and status
- handle_list_data, handle_get_data_item, handle_put_data_item each
  return 400 when req.matches is empty (missing route capture groups),
  exercising the guard check before ctx_.node() is accessed

Tests use a null GatewayNode and null AuthManager, which is safe because:
- handle_data_categories/groups call only HandlerContext::send_error() (static)
- The other three handlers check req.matches.size() before using ctx_.node()

Closes selfpatch#180

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 a new GTest unit test suite for the DataHandlers HTTP handler layer in ros2_medkit_gateway, focusing on SOVD-compliant error responses for unimplemented endpoints and early-guard behavior for missing route capture groups.

Changes:

  • Adds a new test_data_handlers.cpp unit test file covering 501 “not implemented” handlers and 400 guard checks for missing req.matches.
  • Registers the new test target in CMakeLists.txt and includes it in coverage instrumentation when enabled.

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_data_handlers.cpp Adds unit tests validating 501 SOVD error bodies for data categories/groups and 400 responses when route matches are missing.
src/ros2_medkit_gateway/CMakeLists.txt Adds/links the test_data_handlers GTest target and includes it in the coverage target 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 DataHandlers

1 participant