Skip to content

Commit

Permalink
fix file loading for unit test (#219)
Browse files Browse the repository at this point in the history
<!-- Thanks for the contribution, this is awesome. -->

# PR Details
This PR updates a unit test in emergency_response_vehicle_plugin which
to use` ament_index_cpp::get_package_share_directory()` to access a csv
file with route destinations. This fixes the unit test which was failing
previously.
## Description

<!--- Describe your changes in detail -->

## Related GitHub Issue
usdot-fhwa-stol/carma-platform#2335
<!--- This project only accepts pull requests related to open GitHub
issues or Jira Keys -->
<!--- If suggesting a new feature or change, please discuss it in an
issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps
to reproduce -->
<!--- Please DO NOT name partially fixed issues, instead open an issue
specific to this fix -->
<!--- Please link to the issue here: -->

## Related Jira Key

<!-- e.g. CAR-123 -->

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->

## How Has This Been Tested?

<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->

- [x] Defect fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that cause existing functionality
to change)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->

- [ ] I have added any new packages to the sonar-scanner.properties file
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have read the
[**CONTRIBUTING**](https://github.com/usdot-fhwa-stol/carma-platform/blob/develop/Contributing.md)
document.
- [ ] I have added tests to cover my changes.
- [x] All new and existing tests passed.
  • Loading branch information
adev4a authored Mar 27, 2024
2 parents f7a1376 + 5c8f821 commit af42cd3
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@


#include <gtest/gtest.h>
#include <ament_index_cpp/get_package_share_directory.hpp>

#include "emergency_response_vehicle_plugin/emergency_response_vehicle_plugin_node.hpp"

Expand Down Expand Up @@ -207,9 +208,7 @@ namespace emergency_response_vehicle_plugin{

worker_node->handle_on_shutdown();
}
// This unit tests has been temporarily disabled to support Continuous Improvement (CI) processes.
// Related GitHub Issue: <https://github.com/usdot-fhwa-stol/carma-platform/issues/2335>
/**

TEST(EmergencyResponseVehiclePluginTest, testLoadRouteDestinationPointsFromFile){
rclcpp::NodeOptions options;
auto worker_node = std::make_shared<emergency_response_vehicle_plugin::EmergencyResponseVehiclePlugin>(options);
Expand All @@ -219,7 +218,10 @@ namespace emergency_response_vehicle_plugin{
worker_node->activate(); //Call activate state transition to get not read for runtime

// Provide file path to getRouteDestinationPointsFromFile() to extract route destination points
worker_node->loadRouteDestinationPointsFromFile("../../install_ros2/emergency_response_vehicle_plugin/share/emergency_response_vehicle_plugin/resource/example_route.csv");
std::string path = ament_index_cpp::get_package_share_directory("emergency_response_vehicle_plugin");
std::string file = "/resource/example_route.csv";
file = path.append(file);
worker_node->loadRouteDestinationPointsFromFile(file);

// Verify size and contents of route_destination_points
ASSERT_EQ(worker_node->route_destination_points_.size(), 3);
Expand All @@ -244,7 +246,7 @@ namespace emergency_response_vehicle_plugin{

worker_node->handle_on_shutdown();
}
*/

TEST(EmergencyResponseVehiclePluginTest, testProcessIncomingUdpBinary){
rclcpp::NodeOptions options;
auto worker_node = std::make_shared<emergency_response_vehicle_plugin::EmergencyResponseVehiclePlugin>(options);
Expand Down

0 comments on commit af42cd3

Please sign in to comment.