test: add unit tests for least-covered modules - #6
Merged
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
cedev-1
approved these changes
Jul 21, 2026
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
Measured per-file line coverage with
cargo llvm-covoncloudreve-apiandcloudreve-sync, then added focused unit tests for the pure-logic modules that were least covered. No production code changed (only a one-line indentation fix indrive/utils.rs).Coverage before → after (lines):
cloudreve-api/src/boolset/mod.rscloudreve-api/src/models/uri.rscloudreve-api/src/error.rscloudreve-sync/src/uploader/encrypt.rscloudreve-sync/src/drive/utils.rsWorkspace line coverage (api + sync) rose ~28% → ~38%. +58 new tests, all inline
#[cfg(test)] mod testsblocks matching the repo's existing style.What the tests exercise:
and/oracross differing lengths, base64 round-trip + decode-error fallbacks infrom_data.CrUri): prefix validation, component parsing, percent-encoding round-trips (set_path/join/join_raw),parent,SearchParamset↔parse round-trips including the trashrestore_urimetadata path andpure_urifiltering.ErrorCode::from_codemapping,is_credential_error, and everyApiError::from_responsebranch (lock conflict, batch w/ aggregated errors, auth→LoginRequired, generic fallback) plusis_token_expired/requires_login.EncryptionConfig): metadata validation (bad base64 / wrong key & IV lengths), CTR reversibility, and that chunkedencrypt_at_offset(both block-aligned and non-aligned offsets) matches a single full-buffer pass — the property the resumable uploader relies on.local_path_to_cr_uri/remote_path_to_local_relative_pathround-trips incl. out-of-root errors, andview_online_url/recycle_bin_urlquery construction.Test plan
cargo test -p cloudreve-api -p cloudreve-syncpasses (mirrors CI). New tests are deterministic and require no network/DB.Link to Devin session: https://app.devin.ai/sessions/47a90a862b514e589db48d6ff39765fc
Requested by: @cedev-1