fix(launch): Added parameter

This commit is contained in:
2025-10-08 18:40:05 +02:00
parent 161b5084fc
commit 6ccbc95b15
8 changed files with 3 additions and 149 deletions

View File

@@ -131,85 +131,3 @@ ssl = false
min_connections = 1
max_connections = 10
```
---
## Unit Tests
Unit tests for `ConfigManager` are implemented in `src/g2_2025_grade_calculator_pkg/test/ConfigManager.test.cpp` using Google Test and ROS2 test utilities. The tests use temporary TOML files to validate configuration loading and parsing functionality.
### Test Cases
#### 1. ConstructorTest
**Description:** Verifies that ConfigManager can be created with a ROS2 logger without crashing.
- **Test Action:** Create ConfigManager instance with ROS2 logger
- **Expected Result:** Instance created successfully without exceptions
#### 2. LoadValidConfigTest
**Description:** Tests loading of valid TOML configuration files with proper parsing.
- **Test Action:**
- Create temporary TOML file with valid configuration
- Call `load_config()` with file path
- **Expected Result:**
- Returns `true`
- `is_loaded()` returns `true`
#### 3. LoadInvalidFileTest
**Description:** Tests error handling when attempting to load non-existent configuration files.
- **Test Action:** Call `load_config()` with non-existent file path
- **Expected Result:**
- Returns `false`
- `is_loaded()` returns `false`
#### 4. DatabaseConfigParsingTest
**Description:** Tests complete database configuration parsing with all parameters.
- **Test Configuration:**
```toml
[database]
host = "test_host"
port = 1234
dbname = "test_db"
user = "test_user"
password = "test_password"
timeout = 60
ssl = true
[database.pool]
min_connections = 2
max_connections = 20
```
- **Expected Result:** All configuration values parsed correctly with proper types
#### 5. DatabaseConfigWithoutPoolTest
**Description:** Tests default values when optional pool section is missing from configuration.
- **Test Configuration:**
```toml
[database]
host = "localhost"
port = 5432
dbname = "grades"
user = "postgres"
password = "postgres"
```
- **Expected Result:**
- Main database config parsed correctly
- Default pool values: `min_connections = 1`, `max_connections = 10`
#### 6. GetConfigWithoutLoadingTest
**Description:** Tests behavior when attempting to access configuration before loading any file.
- **Test Action:** Call `get_database_config()` without loading configuration
- **Expected Result:**
- Returns `std::nullopt`
- `is_loaded()` returns `false`

View File

@@ -123,69 +123,3 @@ if (db_manager.is_connected()) {
}
}
```
---
## Unit Tests
Unit tests for `DatabaseManager` are implemented in `src/g2_2025_grade_calculator_pkg/test/DatabaseManager.test.cpp` using Google Test and ROS2 test utilities. The tests are designed to work reliably whether a database connection is available or not, focusing on error handling and method behavior validation.
### Test Cases
#### 1. ConstructorTest
**Description:** Verifies that DatabaseManager can be created without crashing and proper initialization occurs.
- **Test Action:** Create DatabaseManager instance with ROS2 logger
- **Expected Result:** Instance created successfully without exceptions
#### 2. ConnectionStatusTest
**Description:** Tests that the `is_connected()` method returns a valid boolean value.
- **Test Action:** Call `is_connected()` method
- **Expected Result:** Returns either `true` or `false` (no crashes or invalid states)
#### 3. QueuePendingCombinationsTest
**Description:** Verifies retrieval of pending student-course combinations that need exam results.
- **Test Action:** Call `queue_pending_combinations()`
- **Expected Result:** Returns valid vector (empty if no database connection, populated if connected)
#### 4. StoreExamResultTest
**Description:** Tests exam result storage with graceful handling of connection states.
- **Test Action:**
- Student: `"TestStudent"`
- Course: `"TestCourse"`
- Grade: `85`
- **Expected Result:** Returns `false` if no connection, `true` if connected and successful
#### 5. EnrollStudentTest
**Description:** Tests student enrollment into courses.
- **Test Action:**
- StudentCourse object with test data
- **Expected Result:** Returns `false` if no connection, `true` if connected and successful
#### 6. GetFinalGradeTest
**Description:** Tests final grade retrieval for non-existent student-course combinations.
- **Test Action:**
- Student: `"NonExistentStudent"`
- Course: `"NonExistentCourse"`
- **Expected Result:** Returns `-1` (no results found or no connection)
#### 7. StoreFinalResultTest
**Description:** Tests storing calculated final course results.
- **Test Action:**
- StudentCourse object
- Exam count: `3`
- Final grade: `75`
- **Expected Result:** Returns `false` if no connection, `true` if connected and successful

View File

@@ -1,5 +1,7 @@
<launch>
<node pkg="g2_2025_grade_calculator_pkg" exec="exam_result_generator"/>
<node pkg="g2_2025_grade_calculator_pkg" exec="exam_result_generator">
<param name="delay_between_grades_ms" value="2000"/>
</node>
<node pkg="g2_2025_grade_calculator_pkg" exec="final_grade_determinator">
<param name="grade_collection_amount" value="5"/>
</node>