test: add firmware service unit tests #85
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
Expand firmware service test coverage to validate file cleanup operations and device service client delegation.
Tests now support parallel execution using mutex lock pattern (refactored from initial implementation).
Tests Added (6 new, 7 total)
clear_data_folder (3 tests)
load_update (2 tests)
run_update (2 tests)
Implementation Details
mockallto mockDeviceServiceClientfor async operationsserde_jsonto constructRunUpdate(private fields)DATA_FOLDER_LOCKmutex following thePASSWORD_FILE_LOCKpattern for test isolationRefactoring for Parallel Execution
Initially,
clear_data_foldertests had a race condition due to shared temp directory fromAppConfig. This has been resolved by:DATA_FOLDER_LOCKmutex (following password.rs pattern)lock_for_test()method toFirmwareService--test-threads=1flagKnown Limitations
File Upload Not Tested:
handle_uploaded_firmwareis not tested as it requires mockingactix_multipart::form::tempfile::TempFile, which is complex.Test Results
All 7 tests pass ✅
Impact
Checklist
cargo fmtSigned-off-by: Jan Zachmann 50990105+JanZachmann@users.noreply.github.com