test(gateway): add unit tests for DataHandlers#234
Open
eclipse0922 wants to merge 2 commits intoselfpatch:mainfrom
Open
test(gateway): add unit tests for DataHandlers#234eclipse0922 wants to merge 2 commits intoselfpatch:mainfrom
eclipse0922 wants to merge 2 commits intoselfpatch:mainfrom
Conversation
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>
Contributor
There was a problem hiding this comment.
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.cppunit test file covering 501 “not implemented” handlers and 400 guard checks for missingreq.matches. - Registers the new test target in
CMakeLists.txtand 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DataHandlershandle_data_categoriesandhandle_data_groupsboth 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 2error_codeand status codehandle_list_data,handle_get_data_item,handle_put_data_itemeach return 400 whenreq.matchesis empty (missing route capture groups), verifying the guard check that runs beforectx_.node()is accessedGatewayNodeand nullAuthManager(safe: 501 handlers only call staticHandlerContext::send_error(); other handlers checkreq.matches.size()before any node access)Test plan
colcon test --ctest-args -R test_data_handlersros2_medkit_dev:latestCloses #180
🤖 Generated with Claude Code